Adding a Flex Nature to an existent Java (WTP) project

Sometimes you already have a J2EE project (made with WTP) and you want to be able to make it also a Flex project. Probably you don’t like the idea of creating a new Java/Flex project and copy the files. Neither do I :D (If you want to create a new Java/Flex project then check my previous posts about creating a Java/Flex project and debugging this project).

Fortunately the solution is there in Flex Builder. You need to select the project in project explorer and right click to bring up the contextual menu for the project. Then you should select Flex Project Nature > Add Flex Project Nature:

Selecting this command will open a wizard that looks like the one for creating a new Flex project (the differences are that some options are disabled as the project already exists and you are just adding new things to it). So here is the first page and you can see you have the option to choose if you want to use LiveCycle Data Services / BlazeDS or not. On the second page you can enter the path for Flex WAR file (if you choose remote object access on first page). Click “Finish” and you got yourself a Java/Flex combined project.

Final words

I will not lie to you, these two features (combined Java/Flex project and Add Flex Nature) are very dear to me as I was the engineer who worked on them for Flex Builder 3 :) But besides the sweet memories and countless meetings to shape up these wizards and endless fights with my quality engineer on what should happen, I had another reason to write my first technical post on this subject: I talked in the last couple of months with Java developers who work with Flex and they didn’t know about these features yet :(

So, I am really curious if you guys find this helpful or not and if there are other things you still need (I have friends inside Flex Builder team so we can push our wishes :) ).

17 thoughts on “Adding a Flex Nature to an existent Java (WTP) project

  1. We have used WTP with flexbuilder, however, it has been very bugy for us. For example, when I do a flex build, the tomcat WTP server does an automatic restart, even though no java class files changed. This causes BlazeDS is reload and causes NOP Logging errors for log4j. Have you experienced any of these problems?

  2. Hi Brian,

    No, this is the first time I’ve heard about this.
    I have just tried this scenario:
    1. Create a Java (WTP) Flex project with LCDS
    2. Starts the Tomcat Server from Eclipse with the project deployed on it
    3. Change in the MXML file a tag and Save the file
    I couldn’t see any restart of the server

    Do you have an easy way to try to reproduce it on my computer or can you post somewhere a project that I can download and try to see if I can reproduce it?

  3. Open up {your project}/.settings/org.eclipse.wst.common.component and add this line to the mix:

    This line seems to be causing the problem in the test project. If you have that line, everytime you save a file your wtp server thinks it needs to republish itself! See if it happens to you? However, in our real project we don’t have anything like this in that file, yet it tries to republish. With BlazeDS, the reload time is painful because it has to recache everything.

  4. Sorry, it appears you have a filter on opening/closing tags:

    wb-resource deploy-path=”/” source-path=”/flex_src”/

  5. This line is also in my config file. If you have some steps to reproduce it you should log a bug here:

    I have tested again on my machine and I couldn’t find any issue. But if you manage to resolve the issue you could safely remove that line.

  6. Hello

    I have a java web project in eclipse that i have deployed to a war file.In the flex project i am using this war file.

    I alternatively write code both in eclipse and flex and i must export to war file every time i modify in eclipse.

    My question is: is there a method to autodeploy to the war file when i modify the java code in eclipse so that the flex builder will see it?

    Thanks in advance

  7. @Sorin

    Right now I don’t see a solution for what you need. But, I am curious why is not OK for you to create Flex and Java Web Project and work on both Java and Flex files from within the same project? This kind of setup it should solve your problem, I think.

  8. Hey…can you explain the other two features…Add Flex Library Project Nature and Add ActionScript Project Nature

  9. @Matthew

    Please refer for the documentation for detailed information. On short, you use an ActionScript project when you don’t want to use Flex library (so you don’t have MXML, only ActionScript classes and Flash API).

    You use Flex library if you want to create a library of components to be reused in other projects.

  10. Very useful feature! I used it to convert an axdt project to a Flex Builder project. You should get them to add it to the help files – I couldn’t find it there.

  11. A suggestion: there should be a way to add an Apollo nature in addition to the Flex nature. I was able to do this by manually editing the .project file, but that also made some weird things happen.

  12. About to try this for an existing Java EE project. If it works for me, “helpful” will not be able to express my gratitude (since I didn’t write the original Java EE project and copying all the files would be much less desirable).

  13. Hi Mihai,

    I am having a J2EE project plus Flex project. But my J2EE project uses webservices.
    can you please explain me how to keep both the projects in a single project?

    I want to compile both the projects and deploy it on Tomcat server.
    Please help.

    Thanks in advance.

  14. @Shrikant

    Did you try to add a Flex nature to your project? Choose as application server none and it should work. Next you can set the output folder of the Flex project wherever you want (this is the folder where you’ll find the compiled Flex application).

    Also, I don’t see why you can’t use a WTP project and leverage the deployment feature of the WTP…

  15. thanks for the post.
    I have a problem by mistake i added the project nature as flex library project. now i am not getting to change this option as actually i want to configure this as flex project and not flex library. Inputs will be helpful.

Leave a Reply