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:eclipseeclipse.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.

89 thoughts on “Creating a combined Flex/Java project in Flex Builder w/o LCDS/BlazeDS

  1. Hi,
    I am very new to Flex Builder and need to create J2EE project. I have already added WTP in Flex Builder 3, but still don’t see “Create combined Java/Flex project using WTP” coming for me. How can I run eclipse.exe with -clean as I don’t find “eclipse.exe” inside Adobe ?


  2. @Anil

    Hi there, you should find the executable inside the Flex Builder installation folder. If you have the standalone version of Flex Builder, it might be named “FlexBuilder.exe”.

  3. Hello folks, well i am a little confused about the use of Flex and java, this is my problem: My java application must read two .zip files from an online server. These classes will load and parse the data in a Thread and perform certain actions depending on such info. The problem occurs when my flex application calls the java method that queries such data. I need to WAIT until the loading has finished. Any ideas?
    Another doubt is if the Java classes are being compiled and transformed into some form of ActionScript classes.
    Maybe I’m lost in space, so please I need a light in the darkness, thank you.

  4. @Christian

    The simplest solution, I think, is to use Data Messaging. Your Flex client is the consumer, and the java classes are the producer.

    Java classes are not compiled and transformed into ActionScript code.

  5. Thanks a lot for you very informative post. It helped me to set up my Flex/Java project with LiveCycle in 15 minutes.

    Keep up the good work!

  6. @Henmang

    If the class stays on the server, then yes. There are two server side frameworks from Adobe (BlazeDS -open source and LiveCycle Data Services -commercial product) that offer RMI style invocation of the exposed classes on the server from the Flex/AIR client. If you search on remoting Flex and Java you’ll find tones of articles explaining this topic

  7. Pingback: Flex and Java in Eclipse « Techie Note

  8. Hi,

    Thanks for posting this nice tutorial but i have a question. I am trying to develop a flex application with java/j2ee. I was wondering how to communicate from one flex page to other using servlet as controller.
    I am trying to develop a small application like login,registration and search from database using Flex as front end and Java/J2ee as back end.

    I hope you would have got an idea i am trying to develop.
    Please help me in this regard.


  9. Thanks for helping me get the project setup with WTP. Can you shed some light on how to deploy a war file with everything packaged correctly via Eclipse? Is there a way to automate this process? When I do Export/ Select War
    /WAR Export/ Destination = tomcat/webapps/flex_project I get the following error:
    java.lang.NoClassDefFoundError: Could not initialize class org.eclipse.jst.j2ee.commonarchivecore.internal.CommonArchiveFactoryRegistry

    I guess I’m missing something in the initial server setup; I’m not clear on how and when the project, or which parts of it, are to be deployed.
    I’m using Adobe Flex Builder 3 on top of
    Eclipse Version: 3.4.2


  10. Mihai,

    Great article but I am not able do this for Flash Builder 4 Beta 2. I don’t see Europa Discovery and see Ganymede Discovery instead. I couldn’t get far in the wizard as it kept telling me of incompatible configuration.

    Help please!

  11. Mihai,

    I am also running Flash Builder 4 Beta 2 on Mac. I want to do combined Flex/Java development. I am supposed to install the Eclipse WTP plug-in to be able to do that. I went through the process you illustrated above for i.e. Help -> Software updates -> Find and install -> Select new features to install. i arrived at 2 options:

    1. Ganymede Discovery
    2. The Eclipse Project Updates

    Ganymede Discovery gives this error message:- “NAB/MWT for Linux GTK ( operating system does not match current environment.”

    The Eclipse Project Updates opens another field with several features under it but does not include WTP plug-in.

    i followed the link you provided to site. Clicked on downloads and this is where I got even more confused. Nothing there made any sense because It was hard to determine one is which. Please help. Thanx in advance.


  12. Hi Mihai Corlan,

    Thanks for your Tutorial, I have one question that while i am configuring target runtime in Flex Builder which is a eclipse plugin i am unable to see my Tomcat v6.0 which i have installed but i can see other earlier versions of Tomcat.What should be the problem.


  13. Hi
    I saw and have installed WTP. I am a novice in this, but i want to try my hand in flex as i have some spare time now. Can you tell me how to create a simple java/flex project using only WTP.
    Say, for populating a string in a textinput area from a javaclass.
    Can you send me or even upload a complete zip folder, so that I can get the directory structure and what goes in which folder and also how the class and mxml will get connect.. Please Someone help me. I have eclipse and flex 3 builder

  14. Hi,

    my projects environment is flex+java+blazeds+spring.
    I have flex builder 3 ide.

    Please tell me if the bove combination would work in flex builder 3 + WTP.

    I just want to make sure before i start development.

    Also Can you help with cvs configurartion in flex builder 3?

  15. @siva

    Yes, it should work. Regarding cvs and Flex Builder 3, you install a plugin that gives you support for cvs and you are good to go…

  16. Pingback: Creating a combined Flex/Java project in Flex Builder w/o LCDS/BlazeDS « Techie Note

  17. I followed the tutorial and got the error:
    “One of rmore constraints have not been satisfied”.

    I use
    “all-in-one” eclipse with wtp
    Flash builder plugin 4
    tomcat 6.0.29

    Page 1:
    1. project name and default project location;
    2. application type: web
    3. sdk version: default sdk (flex 4.1)
    4. server technology: j2ee, BlazeDS
    5. checked creating combined java/flex using wtp
    6. java source folder: src

    Page 2: j2ee settings:
    Target runtime: Apache Tomcat v6.0
    context root and content folder: take default
    blazeDS war: pointing to my downloaded blazeds.war
    out-put folder: bin-debug

    Page 3: Main source folder and Main application file: take default

    Output folder URL: http://localhost:8080/myproject/

    Errors are encountered while creating the project
    reason: One or more constraints have not been satisfied.

    Would you please point out what I missed or did wrong. Thank you.

  18. Mihai

    Please advise me as to how to install WTP files in Flash Builder 4. Typically, what files need to be in FB4? i am running a Mac. Thanx.


  19. I also get the “One or more constraints have not been satisfied” error when creating a new Flex project. The Eclipse I am using is called SpringSource Tool Suite 2.5.1

    Any idea where I can at least find more info on what the constraints are…

    I am able to run the Flex 4 TestDrive with no problem


  20. Pingback: Create a Flex-Java project in Flex Builder 3

  21. Pingback: Create a Flex-Java project in Flash Builder 4

  22. Hi,
    for this error “One or more constraints have not been satisfied” is caused by Helios eclipse u can solve this by using a previous version like ganymed or galileo ..
    thank’s for the article

  23. Pingback: Confluence: Tech Stuff

  24. Pingback: Confluence: Tech Stuff

  25. Pingback: Confluence: Tech Stuff

  26. hi i have installed wtp tool in flex builder.
    when i write java class and run that is working fine.but when i work together Flex with java it is not working.i already deployed flex war file .
    i edited remote config.xml file for Flex to java class. but it shows the error as send failed.
    Is there any other thing i have to do in my flex builder 3 for connection flex to java methods?

  27. Hi,

    I am using Flex builder4.5. I am using eclipse 3.6. The plugin is installed. Blazeds also working fine. When I am creating a flex projec it is not showing option to run as flex application(for mxml file which is an application file). Can any of you please help me in this. It is very urgent for me.


  28. Hi,

    One of our customers is having lot of Java and Flex based applications and now customer wanted an idea on how to conver t these applications to HTML 5 based responsive web apps + wherever applicable migrate to iOS based native apps as well.

    what is the best way to convert ? does starting from scratch of the mobile development make sense ? or any short cut to convert while reusing some of the code ? Please give some direction.

Leave a Reply

Your email address will not be published. Required fields are marked *