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.
Comments
71 Responses to “Creating a combined Flex/Java project in Flex Builder w/o LCDS/BlazeDS”
Leave a Reply













[...] my previous post I described how you can install WTP in Flex Builder and how you can create a combined Java/Flex [...]
[...] 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 [...]
Very good
thanks
[...] 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 [...]
[...] 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 [...]
[...] 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 [...]
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…….
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
@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.
[...] 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. [...]
Merci, this helped a lot!
Hello!,
Good day!,
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?
[...] 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 [...]
[...] Creating a combined Flex/Java project in Flex Builder w/o LCDS/BlazeDS [...]
with flex builder 3 build-3.0.194161 i am not able to update WTP.
@prakash S
Thank you for telling me. Could you log a bug at http://bugs.adobe.com ?
many thanks!
thanks! this tutorial has been really useful to me! seems like preparing Flex+Java is harder than actually building applications with those.
@Francesco Paolo Schiavone
I wouldn’t go so far
Thanks!
Very nice. It is too much helpful. Appreciate your effort.
Thank You Very much !!
Thank you a million for the doc. But I could not browse my Flex-J2EE application “table2.mxml” with LCDS2.6.1 and Flex builder3.0.1.205647.I use tomcat6.0.18 as my J2EE server. but I can just got ‘XML’ document instead of the compiled swf application when I submit “http://localhost:8080/J2EE2/table2.mxml”. It seems that “table2.mxml” are not compiled to swf application on the server side.
Can you give me a hand?
@lihua
I think the application file wasn’t created with the wizard new MXML application. Other than this, I don’t see any problem. Are you sure you have a project that has both Flex and WTP natures?
Good luck!
Hi, Mihai,
Yeah, I have a project that has both Flex and WTP natures. And now I have solved the problem. It is the problem of LCDS2.6.1. I uninstalled it and install LCDS2.5.1. Everything is OK now. With LCDS2.6.1, I could not access .mxml on server directly.
Thank you so much.
thank you so much Mihai
[...] in so many places so I don’t want to insist on that – take a look for example at my colleague post. Instead I will write what to do when you already have an application packaged as WAR and you [...]
[...] Web Tools Project Eclipse plugin (Extremely useful tool to do simultaneous Flex and Java development. Installation instructions are available here [...]
This is good as the war file is automatically generated whenever the code is changed. Is there a way to specify war file name as it is .war?
Hi,
In this kind of java+flex project will the FlexBuilder compile the java source files or oes it need another script for compilation?
Thanks
@shanti
java files are compiled by JDT (Java Development Tools) plugin. Flex Builder doesn’t have any compiler for Java. JDT is part of the WTP installation.
Hi i’m trying to export a flex/J2EE application as a release build but it generates me an error “An error has occurred. See error log for more details.java.lang.NullPointerException”.
Please can you help me.
@shinigami00
I have no idea what could be wrong. Maybe you can have a look on the forums, or submit/check a bug on http://bugs.adobe.com for Flex Builder.
PS. fun of Bleach?
Thnks anyway. I just exported my application as a .war file and deployed it in my SSL/Tomcat server and it’s working fine. no need to export it as release build application.
Plsssss help me people…. it made me depress!
how to install WTP (Web Tools Project) on Flex Builder 3???? How???
i can not even install “Web and JEE Development” from the Hepl-find and install-search for new feutures… the error is: ” Eclipse XML Editors and Tools (2.0.2.v200802150100-7A1ECMCnbcl1bVs9uNm_Zkieb7Qe) requires plug-in “org.eclipse.emf.common (2.2.0)”, or compatible.”
@Meysam
After you select “Web and JEE Development” and press “Select required” you will have automatically selected all the required plug-ins (do not uncheck anything!), all you have to do is to press the Next button.
Cristi thanks!!!! i got it! thanks!!!!!
[...] ar fi mai usor sa lucrezi cu LCDS daca iti instalezi si WTP in Flex Builder: [...]
Dear Sir,
I followed the instruction as you said. I worked in the part of creating project.
But when i run the project it simply says cannot find the resources. i manually started the tomcat server as well as i let be down automatically from the flex.
Do i need to change something in the web.xml file.
Please help me
Your’s
Robin Thapa
Opps im sorry for my mistake,
Hahahahah finally it worked, i read ure tutorial once again and i corrected my mistake.
Thank you for your kind help
@Robin
Can you post what you did wrong? Just to help others that may do the same thing…
Dear Sir,
i completed the set up as you have described above and its working.
But i cant compile my java class from flex builder3.
Can you put a tutorial as how to simple write a simple java class and display a string return from the java class to the browser using flex.
Please help me, i am interested in learning flex.
I hope you get what i said?My English is poor.
Thank you,
Robin
@Robin
take a look here: http://www.adobe.com/devnet/flex/flex_java.html
you should find what are you looking for.
Thanks For your help ,
It worked for me !!
I can say Java -Flex is the best combination among all others …
Hello
Thanks for give idea about configure flex and java project.But one important things is how The Add/remove project option is enable.This happened add webproject capability in your project.Then only you can deploy your project in server.(right click your project-> My eclipse->Add web service capability)
Thanks,
Mejat
Hi All,
i have WTP plugins , and Flexbuilder how can i activate the wtb plugins Flex3.While creating the new project am not getting the combined flex and java project. can any one help regarding this.
thanks
suman
Thanks,
You provided the additional clarification I needed when the wizard prompted me for the “flex war” file.
Hello,
Can somebody suggest how to add JBoss server to the target runtime?
I am getting this error:
Missing classpath entry \your_server_root\appservers\jboss\bin\run.jar
Please suggest!
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 ?
Thanks,
Anil
@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”.
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.
@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.
thanks for the tip. works great!
hello!
we have finished as you said in the article,but we can not run on server.It simply said can not find the resource.the url is http://localhost:8400/WTP_test/WEB-INF/classes/WTP_test.mxml/
@toswf
I think you made a mistake, because normally the URL should look like this: http://localhost:8400/WTP_test/WTP_test.html
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!
Hi,
Is it possible to directly invoke a java class from flex application?
Thanks.
@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
[...] Flex and Java in Eclipse Posted on October 8, 2009 by mylblog http://corlan.org/2008/06/05/creating-a-combined-flexjava-project-in-flex-builder-wo-lcdsblazeds/ [...]
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.
Thanks,
Rakesh
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
Thanks!
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!
Hi Santosh,
Europa is the older version auf eclipse 3.3
Ganymede is the name of version 3.4
see
http://en.wikipedia.org/wiki/Eclipse_ide
So take ganymede and it should work!
By
mz
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 (0.9.9.200806181757) 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 Eclipse.org 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.
sbliss
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.
Regards,
Naveen.
Hi Mihai Corlan,
Thaks for the tutorial. It really helped alott..
Regards,
Katam
I admire what you have done here. Thank you for sharing. We will look forward for your future updates.
Thanks
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
@Anna
Please have a look at this:
http://www.adobe.com/devnet/flex/flex_java.html
and here
http://www.jamesward.com/2010/01/17/flex-4-and-java-spring-hibernate-in-flash-builder-4/