8 Replies Latest reply on Apr 23, 2010 1:29 PM by Ansury

    Eclipse setup JAVA/Flex


      What are the steps within Eclipse to create a Flex web page so when I click a button I connect via JAVA to the database I get the data...


      like this example,



      I am trying to develop, deploy this exact example from within Eclipse and I am confused.  I switch to the Java view for java development, next I switch to Flex in a NEW project for Flex development...then "Run" and point to the Workspace of the JAVA project...


      Is this the best approach?


      Thank you,


        • 1. Re: Eclipse setup JAVA/Flex
          Ansury Level 3

          A few different ways of doing this and I'm not sure I've settled on a "best" way yet.  That example uses that Blaze 'turnkey' thing.. meh.  I think it kinda dumbs things down and distracts from how to really get started.


          You could create a "combined" Java/Flex project by:

          -Installing the Flex Builder plugin for Eclipse (But oops - doesn't seem to be compatible with the latest version with EE support! At least, it refused to install when I tried it.  I believe it complains about a missing "configuration" folder when it's clearly not missing...)

          -Installing Flex Builder standalone and pulling in WTP to create the same type of project.

          http://corlan.org/2008/06/05/creating-a-combined-flexjava-project-in-flex-builder-wo-lcdsb lazeds/

          I would give this link a try first.  (Unless you're developing in a secure/offline environment, then maybe not since it complicates things.)


          This will create a project with your Flex and Java source/libs at the same level.  I'd give this a shot first and see how you like it.  If you find that you keep getting "mixed up" when switching to/from Flex and Java perspectives (a problem I still am trying to break the habit of), you might want to consider a different project structure.  This option is probably Adobe's more recommended method I assume since their IDE supports it directly, but it's more "invasive" into your Java environment, say if you wanted to replace Flex with something else but keep your Java code (can't imagine why you'd want to do this though ).


          A second option is to install Eclipse and Flex Builder standalone separately.  Create your Java project, and then create your Flex client project inside the Java project (they can't be in the same folder because files like .project will conflict of course).  This requires you to do a little thinking about how you're doing your builds (use the Flex ant tasks) but has some subtle advantages which I won't go into too much.  One is that your "Java guys" don't need to have Flex Builder installed at all and can work with just (free) Eclipse.  This is probably the most flexible option but you do need to be prepared to work out solutions to minor issues such as where to put services-config.xml.  (It belongs in the Java project's WEB-INF/flex folder, but I know of no way for the Flex project to refer to it since it's outside the project.  My solution was to eliminate the dependency, i.e. by creating channels dynamically via ActionScript or a ChannelSet tag.)


          A third option which I've never really tried (but heard about from someone who didn't like it too much) would be to create two totally separate projects (not embedding one in a folder within the other), and then figure out a way to link the two projects together for purposes of building your war file.  If you like running Ant from a command line as some people do (I don't) this might work fine, but I don't think it'd be so nice building with Ant from Eclipse.  Just throwing this out there since who knows, it may work out better in someone's environment... maybe if migrating a Flex client's back end from something to Java, or developing multiple types of 'back end' architectures for the same client.

          • 2. Re: Eclipse setup JAVA/Flex
            pr1440 Level 1

            Thanks for the detailed response...I agree it is dummed down a bit too much.


            I had used the third option but ran into trouble when looking to add a second Flex file...


            I chose that approach because I have using a JAVA plugin called MyEclipse which simplifies deployment for java projects.  The plugin won't work in Flex builder so I am using Eclipse with the Flex Plug-In.  What I had done with the Flex project was point the "Run" of the Flex project to output to the workspace of the JAVA project.  Again, adding a second Flex file is a problem with this approach.


            I like the one directory approach but don't think it will work with the MyEclipse plug-in...mucking around with ANT is not for me...


            I could live with the one Flex project, one JAVA Project approach if I could figure out why it won't let me add a sceond, or third...Flex file and output to the JAVA project workspace as I have been doing?


            Any ideas?




            • 3. Re: Eclipse setup JAVA/Flex

              Ansury gave quite a good response already, I'll just add some of my personal experiences.


              I have one app where the client (Flex) and the server (Java EE) and two completely different projects on the Flex Builder. Works just fine, When modifying the Java parts, Eclipse will automatically compile and deploy the source to the Tomcat. The client part works in a similar way, I can run and debug the code inside Eclipse. The problem here is that when debugging the application, the swf is not inside the war. For the release build we have an ant script that creates a deployable war file out the two. This scenario has the problem that the programming environment and the release environment are not identical, so we need also a test environment which is identical to the release environment (well we'd probably need the test environment anyway, so maybe it's not such a big problem)


              On another app I have one ant script compiles everything and even deploys it to Tomcat. I have configure Eclipse to use the build.xml automatically. This is nice and works well, but requires some more work to be set up. Good thing about this is that it's not IDE dependant. As one more downside, it requires an additional debugger.


              For the second project I tried the combined Java/Flex project setup, but that seemed like a real hassle, so I went with the ant approach.


              Hope this helps you to make your decisions.

              • 4. Re: Eclipse setup JAVA/Flex
                pr1440 Level 1

                2 project approach it is...MyEclipse takes care of the deploy for me, no need for ANT.




                • 5. Re: Eclipse setup JAVA/Flex
                  Removable Eye



                  You mentioned that you are using Eclipse with a Flex plugin. I haven't been able to find a Flex 4 plugin. Where did you find the Flex 4 plugin to use with Eclipse?


                  I'm new to all of this if the answer if obvious.



                  • 6. Re: Eclipse setup JAVA/Flex
                    pr1440 Level 1

                    I am using version 3

                    • 7. Re: Eclipse setup JAVA/Flex
                      Ansury Level 3

                      Removable Eye wrote:




                      You mentioned that you are using Eclipse with a Flex plugin. I haven't been able to find a Flex 4 plugin. Where did you find the Flex 4 plugin to use with Eclipse?


                      I'm new to all of this if the answer if obvious.




                      If you want to try the Flex Builder plugin (actually I guess it's a 4th option) it should still be a choice when you install as usual from your FB CD.  In my experience however you can run into compatibility issues with later versions of Eclipse.


                      Myself, though, I'm not using the plugin now.  Perhaps it's just me but I keep going back to having standalone Eclipse and Flex/Flash Builder installs, and simply putting the Flex client project inside the Eclipse project.  (Described above as the "second option".)  Perhaps I should change my recommendation to that option instead.  The only point of complication is services-config.xml, but nowadays there are a number of people using various methods to eliminate the services-config dependency.


                      I don't recall any major problems with option 1 above, so it's probably just a matter of preferences (one of my dev environments is secure/offline, greatly complicating option 1) and your work environment/requirements.

                      • 8. Re: Eclipse setup JAVA/Flex
                        Ansury Level 3

                        jake_flex wrote:


                        I have one app where the client (Flex) and the server (Java EE) and two completely different projects on the Flex Builder.


                        A good addition, this is a detailed account of the third option I presented above.  Personally I still like being able to have a single project in SVN source control (rather than 2 distinct projects), but it's a preferences thing.  When you're working with Java-only guys, you have to make sure they remember to update the Flex client code too, if it's embedded in the project, it's harder to forget. 



                        Perhaps some day I'll put together a site or blog post laying out all these options and the pros/cons of each.  There really is quite a few types of Flex development environments in use out there, and I'm always on the lookout for the ideal.