Creating a combined Flex/Java project in Flex Builder w/o LCDS/BlazeDS

Whenever I work on a Flex project with Java backend I create a project in Flex Builder that combines Java and Flex. I find that this is the easiest way to work even if I don’t touch at all Java code and I just mess around with Flex/AS files. This is one piece of news brought by Flex Builder 3.

What advantages do you have using this setup? You can edit/run/debug both Java and Flex files in the same editor and same project; you can see the changes as soon as you save the modified files.

Let’s see what you need and how you can create a combined Flex/Java project with or without LiveCycle Data Services or BlazeDS.


Installing WTP (Web Tools Project)

In order to be able to create the combined project you need to have installed WTP (Web Tools Project - this is an open source Eclipse plugin that adds J2EE capabilities into Eclipse). If you start the New Flex Project Wizard and select J2EE from server technology and you don’t see the option “Create combined Java/Flex project using WTP” it means you need to install it.

For this you go to Help > Software Updates > Find and Install… Then select “Search for new features to install” and click Next. You should see something like this (select Europa Discovery Site) :

After this you follow the dialog screens and at some point you will see this screen (you press the “Select Required” button and Next, Next, Next and Finish):

Possible problems installing WTP in Flex Builder: sometimes although you have installed WTP you don’t see the option “Create combined Java/Flex project using WTP”. The solution is simple: type in a console the path to the eclipse executable and add “-clean” option; for my machine this command looks like: “c:\eclipse\eclipse.exe -clean”. After this you should be good to go.

Create the combined Java/Flex project

Let’s open the New Flex Project wizard and select from “Application server type” combo-box “J2EE” and make sure that the option “Create combined Java/Flex project using WTP” is checked (check the first image from this post if you need help). If you want to create a project that is using LCDS (LiveCycle Data Services) or BlazeDS you need to check “Use remote object access service”. Click “Next” and you see this page:

In the second page of the wizard you need to pay attention to “Target runtime”. WTP has a wonderful feature: you can configure your local J2EE server using a simple wizard and then Eclipse can deploy your application and can start/stop/republish the application on this server; all of these are happening from within Eclipse. This “Target runtime” is exactly what this thing does: it lets you associate your project with an already defined server or to define a new one. Click on the “New” button and you will see this wizard:

WTP supports the following J2EE servers: Tomcat, JBoss, WebSphere, JOnAS4, Oracle OC4J Standalone. From my experience the best for developing is the Tomcat: it is the fastest in terms of starting/ restarting/ redeploying. After you selected the desired server click “Next”.

In the second page of the wizard you need to browse for the server installation folder:

Click “Finish” and we are back to new Flex Project wizard. We select the target runtime from the combobox. If you choose on the first page to use LCDS, then on this page you need to browse for the path to Flex WAR file: if you want LCDS you should look for the file lcds.war under the installation folder and if you want BlazeDS you should look for blazeds.war under the blazeds folder. With this we are done and we can click “Finish”.

Once the project gets created you can play with the perspectives and change between Flex perspective and Java or J2EE perspective:

Run the project

So we have the project. Let’s see how can we run it. As I said before, WTP make this task child’s play. First thing we need is to be sure we have “Server” view displayed (if not you go to Window > Other Views… and select Server from the tree).

The first time you want to run a project you need to associate the project with the server - you do this only one time. You just right click inside the Flex application file and choose from the contextual menu Run As > Run on Server option:

This command will open this little wizard (you select the previously defined server and then click “Finish”):

After this the project gets compiled, the server is started and the project is deployed. At this point if you are looking inside the Server view you should be able to expand the Server node and see that a child exists with the same name as the project and the status of the server should be Started and Synchronized:

Now every time you change something in your project as soon you build the project, the project is redeployed automatically. And when you want to see the Flex application you choose Run As > Flex Application (the default browser is opened with the Flex application inside). Also because the project is associated with the server you can use the top right buttons from the Server view to start / stop / debug / publish.

This is it. In my next post I will talk about debugging Java and Flex code using this type of project.

Comments

21 Responses to “Creating a combined Flex/Java project in Flex Builder w/o LCDS/BlazeDS”

  1. Debugging a combined Java/Flex project : Mihai CORLAN on June 6th, 2008 11:45 am

    [...] my previous post I described how you can install WTP in Flex Builder and how you can create a combined Java/Flex [...]

  2. Adding a Flex Nature to an existent Java (WTP) project : Mihai CORLAN on June 7th, 2008 6:24 am

    [...] Neither do I (If you want to create a new Java/Flex project then check the my previous posts about creating a Java/Flex project and debugging this [...]

  3. jyothi on June 13th, 2008 1:04 pm

    Very good

  4. Mihai Corlan on June 13th, 2008 11:34 pm

    thanks :)

  5. Dr Flex & Dr LiveCycle » What is the preferred LiveCycle Data Services development environement on June 18th, 2008 2:24 pm

    [...] Flex Builder and add the WTC plugin.  Mihae Corlan has described the second option. In his post you can also find how to create a combined Flex/J2EE project and how to add the Tomcat [...]

  6. Miti’s Blog » Blog Archive » AS and Flex Project trick on July 4th, 2008 9:19 am

    [...] trying to use the FDS AJAX Bridge to push some messages in an AJAX grid. So I’ve created a Flex + WTP + BlazeDS project and went to change the default Application from the default MXML file to my FDMSBridge.as [...]

  7. SQLAssembler: create a Flex and Java application with LCDS (LiveCycle Data Services) without server side code : Mihai CORLAN on July 8th, 2008 7:05 pm

    [...] can download it for a trial from here; if you don’t have WTP installed, then check my article here; finally if you don’t have LCDS, you can download it from here. I use a combined Flex and [...]

  8. Confluence: PereCEP on July 30th, 2008 6:49 pm

    FlexLCDSDemo…

    Intro The notes below should explain how to demo a Flex client using LiveCycle Data Services. Prerequisites You should have Tomcat (or other JEE web server) and ActiveMQ installed…….

  9. David on August 7th, 2008 4:29 am

    Can you please write something about how to export a WAR file of the combined project? In eclipse, when doing a export/war the entire source code of flex is being added to the war file (even if you uncheck “Export source files”)

    Other than that - excellent articles and thanks a million!

    David

  10. Mihai Corlan on August 7th, 2008 10:48 am

    @David

    There is a trick you can do. Just open the the file .settings/org.eclipse.wst.common.component from your project and comment the node with the attribute source-path=”/flex-src”.

    This should solve your problem.

  11. Criando um projeto Flex/Java + BlazeDS no Eclipse | Vítor Avelino on August 17th, 2008 5:17 pm

    [...] Creio que ficou claro como criar um projeto Flex/Java + BlazeDS no Eclipse. Futuramente irei postar um outro tutorial ou screencast com um exemplo de comunicação Flex/Java. Este tutorial foi feito baseado nesse post. [...]

  12. Frank on August 29th, 2008 8:25 pm

    Merci, this helped a lot!

  13. name on September 1st, 2008 4:58 am

    Hello!,

  14. name on September 1st, 2008 8:51 am

    Good day!,

  15. Khoa on September 11th, 2008 4:53 am

    Hi David,

    Would you please give me direction on how i can deploy both java and flex in one go. Flex and Java is deploy in weborb and weborb is then deploy in tomcat. What will be the setting for the J2EE server? Should i point to Weborb or the tomcat server?

  16. Miti’s Blog » Blog Archive » AS and Flex Project trick on October 15th, 2008 1:07 pm

    [...] ago I was trying to use the FDS AJAX Bridge to push some messages in an AJAX grid. So I created a Flex + WTP + BlazeDS project and went to change the default Application from the default MXML file to my FDMSBridge.as [...]

  17. Creating a combined Flex/Java project in Flex Builder w/o LCDS/BlazeDS | WOWWW! on November 12th, 2008 2:02 pm

    [...] Creating a combined Flex/Java project in Flex Builder w/o LCDS/BlazeDS [...]

  18. prakash S on November 20th, 2008 10:01 am

    with flex builder 3 build-3.0.194161 i am not able to update WTP.

  19. Mihai Corlan on November 20th, 2008 5:51 pm

    @prakash S

    Thank you for telling me. Could you log a bug at http://bugs.adobe.com ?

    many thanks!

  20. DDDepressionnn on November 21st, 2008 12:00 am

    There has come winter :(
    It became cold and cloudy!
    Mood very bad :(
    Depression Begins

  21. DDDDepressionnnn on November 21st, 2008 7:46 am

    Depression Depression Depression aaaaaaaa
    HEEEEELP :( :( :(
    I hate winter! I want summer!

Leave a Reply