Setting Up Eclipse For Flex 2

Posted By : todd sharp Posted At : March 26, 2007 7:20 AM Posted In: Flex

36

Back in 2005 Darron Schall posted Setting Up Eclipse For Flex. A great article, but with the release of Flex 2 it has become a little outdated. I took some time this weekend to set up Eclipse for Flex 2 and thought I'd revise Darron's post a bit to bring it up to speed for those of us who don't generate the revenue to justify Flex Builder but still like to play with it (aka are too cheap to buy it). So here are the steps to get Eclipse up and running. Don't forget that the Flex 2 SDK is completely free so you now have no excuse for not getting into Flex anymore :)

The following steps assume that you're already running the latest version of Eclipse.

Step 1

Download and install the Eclipse Web Tools Platform. As of this post the current version is 1.5.3 so that's where the download link above will take you. Go here if you want to check for a newer version. You really just need the Web Standards portion to set Eclipse up to edit .mxml files - so don't worry about the J2EE project (unless you really want that).

Here's a complete list of files to download.

  • emf-sdo-xsd-SDK-2.2.2.zip
  • GEF-SDK-3.2.2.zip
  • JEM-SDK-1.2.3_jem.zip
  • wtp-wst-R-1.5.3.zip (or the complete Web Standards Tools download)

Step 2

Unzip and copy the contents of each package into Eclipse's Features and Plugins directories respectively. The Web Standards Tools are now installed (well, assuming you've restarted Eclipse if you had it running).

I'm going to borrow some of Darron's original post from here and modify as appropriate:

Now that the appropriate plugins are installed, we need to configure Eclipse to recognize .mxml.

Start Eclipse

From the menu, select Window -> Preferences. Select General -> Content Types. On the right, expand Text and highlight XML. Click the "Add" button and enter "*.mxml" as the file type. Click OK.

Still in the Window -> Preferences menu, expand "Web and XML" and select "XML Catalog". Click "User Specified Entries" and click "Add" and use the following values.

* URI: browse for the path to the mxml.xsd file (something like: C:\Program Files\Macromedia\Flex\extras\schema\mxml.xsd) Updated from original post: The mxml xsd does *not* ship with the Flex 2 SDK. Tom Chiverton has updated the 1.5 xsd for Flex 2 (available here) but it is not 100% updated. I exchanged emails with Tom yesterday and he did say that he had a new version that he will post online soon. Hey Adobe...we really love your product...can you please give us the xsd??? :)

* Key: Edited from original post http://www.adobe.com/2006/mxml

Click OK to close the preferences window.

That's it! Eclipse should now recognize any tags using the mx: namespace (well, all those that are in the xsd that is) and will give you the appropriate mxml code hints as you code. One catch - thanks Tom for pointing this out - is that when you're within a tag (IE <mx:Button>) you'll need to hit CTRL+Space to bring up the attribute hints.

So I hear you saying "That's great! I can now code Flex applications without Flex Builder a little easier. But how can I compile them easily?" Well there are several ways to do that, but that's another post :) I am also working on a tool to help manage small Flex projects that will help you compile and generate HTML wrappers (without messing with ANT).

Related Blog Entries

Comments (36)

Carsten's Gravatar this is soo great - thx a lot man !

Kuldip D Gandhi's Gravatar Thanks Buddy, You have done a gr8 job for all Flex Learners & enthusiasts.

Kuldip D Gandhi's Gravatar How can We Compile mxml files from Eclipse?

chris's Gravatar Yeah, give us an hint on compiling :)

denix's Gravatar Thank man! one day a free eclipse plugin will see the light!

Tom's Gravatar For those using MyEclipse you can find the XML Catalog under Window -> Preferences -> MyEclipse -> Files & Editors -> XML -> XML Catalog

Travis's Gravatar I am using eclipse 3.2.2 and can't for the life of me find the Window -> Preferences -> Web and XML - I can't seem to find the XML Catalog at all - am I missing something completely?

ArmEagle's Gravatar Travis i seem to have the same issue. I spooked around the IRC channel a bit and finally got a way to get that "Web and XML" entry..

First, I have Eclipse 3.2.2. I downloaded 'EMF' (http://www.eclipse.org/modeling/emf/downloads/?pro...).
Get version 2.2.3! (Not 2.3.0!).
Then I could install 'WST' using the Help-> Software Updates .. -> .. Callisto and then the last entry. Click the button that checks requirements.

Once this is all finished I have the 'Web and XML' entry.

ArmEagle's Gravatar Oh.. wait.. i guess i had downloaded too high versions of the files all the time.

Carl's Gravatar I could not find Window -> Preferences -> Web and XML either and I was using eclipse 3.2.2. To fix this make sure you install all the files listed at the beginning of the article (eg emf-sdo-xsd-SDK-2.2.2.zip, etc)

Andreas's Gravatar Great work. Works fine for me.

One Question:
I'm looking for a actionscript plugin (syntax, hints, etc.) for eclipse that works in combination with your flex plugin.

If I use this one:
http://sourceforge.net/projects/aseclipseplugin/
there is no syntax hightlighting of as - code in *.mxml files.

Do you know a solution?

Thanks a lot for your work so far.

Jeremiah LaBresh's Gravatar Ok, so if you use the latest and greatest, of eclipse, you can install oxygen for free from here (see the eclipse install) http://www.oxygenxml.com/download.html

Hope this helps

calif's Gravatar I use eclpise3.3, how to get "Web and XML"?
Thanks!

todd sharp's Gravatar Calif - I'm running 3.3 and had no problems - are you sure you installed all of the correct files listed above?

joolz's Gravatar Doesn't work for me. I've installed it all twice, carefully.

Even though I browse to the .xsd file, if I shut the preferences window and re-open it, I get a message in red saying that the .xsd file can't be found. This is because Eclipse changes the path to the .xsd file to something that actually can't be found. No matter where I put it, it can't find it.

So after all this effort, eclipse is about as useful in this context as Notepad.

Marian's Gravatar Hi Todd!

Thanks for the tutorial. I tried it, but it seems as if something went wrong. I get no syntax highlighting and no code completion when opening/editing an mxml file.

I installes the WTF through the plugin manager directly in eclipse.

Do you know what could be the problem?

Q's Gravatar It's not working... I get

java.lang.NullPointerException
   at org.eclipse.wst.sse.ui.StructuredTextEditor.update(StructuredTextEditor.java:3047)
   at org.eclipse.wst.xml.ui.internal.tabletree.XMLMultiPageEditorPart.addSourcePage(XMLMultiPageEditorPart.java:338)
   at org.eclipse.wst.xml.ui.internal.tabletree.XMLMultiPageEditorPart.createPages(XMLMultiPageEditorPart.java:505)
   at org.eclipse.ui.part.MultiPageEditorPart.createPartControl(MultiPageEditorPart.java:276)
   at org.eclipse.ui.internal.EditorReference.createPartHelper(EditorReference.java:596)
   at org.eclipse.ui.internal.EditorReference.createPart(EditorReference.java:372)
   at org.eclipse.ui.internal.WorkbenchPartReference.getPart(WorkbenchPartReference.java:566)
   at org.eclipse.ui.internal.PartPane.setVisible(PartPane.java:290)
   at org.eclipse.ui.internal.presentations.PresentablePart.setVisible(PresentablePart.java:140)
   at org.eclipse.ui.internal.presentations.util.PresentablePartFolder.select(PresentablePartFolder.java:268)
   at org.eclipse.ui.internal.presentations.util.LeftToRightTabOrder.select(LeftToRightTabOrder.java:65)
   at org.eclipse.ui.internal.presentations.util.TabbedStackPresentation.selectPart(TabbedStackPresentation.java:394)
   at org.eclipse.ui.internal.PartStack.refreshPresentationSelection(PartStack.java:1144)
   at org.eclipse.ui.internal.PartStack.setSelection(PartStack.java:1097)
   at org.eclipse.ui.internal.PartStack.showPart(PartStack.java:1311)
   at org.eclipse.ui.internal.PartStack.add(PartStack.java:455)
   at org.eclipse.ui.internal.EditorStack.add(EditorStack.java:102)
   at org.eclipse.ui.internal.PartStack.add(PartStack.java:441)
   at org.eclipse.ui.internal.EditorStack.add(EditorStack.java:111)
   at org.eclipse.ui.internal.EditorSashContainer.addEditor(EditorSashContainer.java:60)
   at org.eclipse.ui.internal.EditorAreaHelper.addToLayout(EditorAreaHelper.java:217)
   at org.eclipse.ui.internal.EditorAreaHelper.addEditor(EditorAreaHelper.java:207)
   at org.eclipse.ui.internal.EditorManager.createEditorTab(EditorManager.java:822)
   at org.eclipse.ui.internal.EditorManager.openEditorFromDescriptor(EditorManager.java:721)
   at org.eclipse.ui.internal.EditorManager.openEditor(EditorManager.java:682)
   at org.eclipse.ui.internal.WorkbenchPage.busyOpenEditorBatched(WorkbenchPage.java:2593)
   at org.eclipse.ui.internal.WorkbenchPage.busyOpenEditor(WorkbenchPage.java:2528)
   at org.eclipse.ui.internal.WorkbenchPage.access$10(WorkbenchPage.java:2520)
   at org.eclipse.ui.internal.WorkbenchPage$9.run(WorkbenchPage.java:2505)
   at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:67)
   at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:2500)
   at org.eclipse.ui.actions.OpenWithMenu.openEditor(OpenWithMenu.java:288)
   at org.eclipse.ui.actions.OpenWithMenu.access$0(OpenWithMenu.java:280)
   at org.eclipse.ui.actions.OpenWithMenu$2.handleEvent(OpenWithMenu.java:184)
   at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)
   at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:928)
   at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3348)
   at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2968)
   at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1930)
   at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1894)
   at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:422)
   at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
   at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:95)
   at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:78)
   at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:92)
   at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:68)
   at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:400)
   at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:177)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:585)
   at org.eclipse.core.launcher.Main.invokeFramework(Main.java:336)
   at org.eclipse.core.launcher.Main.basicRun(Main.java:280)
   at org.eclipse.core.launcher.Main.run(Main.java:977)
   at org.eclipse.core.launcher.Main.main(Main.java:952)

JonR's Gravatar The last post looks like the error you would see if you tried the ASDT plugin 090beta and tried to open as AS file outside of an ActionScript project before specifying the core classes location.

Try specifying the core classes location (under Windows-Preferences, ActionScript2, Core path). If you have flex2 sdk specify the lib directory.

Then change to ActionScript2 perspective and create a project then move your AS sources there and try to open from your project.

The other exception you would see if you used the ASDT 085 release is a ClassCastException under the same circumstances. If you set the core path and open the files under a project then all is well. At least with Eclipse 3.3

madhav's Gravatar hi , this is bizzare and no one seems to have run into it so far. I've installed eclipse europa 3.3.1.1 and eclipse wtp but when I try to install flex 2.0 with eclipse plug in, flex installation is unable to recognize the directory of flex installation . I just get an error message saying "eclipse verion 3.1 or higher must be installed" . Eclipse installation seems to be fine tough. Any help in resolving this is appreciated.

Arpan's Gravatar Hi, I am also facing the same issue as madhav is... can you help us out please.

guns's Gravatar I am having the same issue with installation. Did anyone resolve this?

Brian's Gravatar I too am having the same problem as madhav. If anyone has any info it would be much appreciated.

Firebubble Web Design's Gravatar Hey thanks for the resources, I'm trying to learn Flex having some difficulties but this has helped. Good article

chin's Gravatar I made all the changes and steps suggested in the post, but I am not getting code completion/ hints. I am not sure, but do we get those features by following the post?

todd sharp's Gravatar Did you try CTRL+Space?

nipt's Gravatar For those of you using Eclipse 3.3.2 and have problems finding the "Web and XML", pleasse follow all the prerequisites found in the following URL http://download.eclipse.org/webtools/downloads/dro... . Install the mentioned JEM-SDK-1.2.3_jem.zip.
And that's it. The "Web and XML" should appear.

going crazy's Gravatar i have spent over 12 hours trying to figure out how to set up Eclipse for Flex. First the Eclipse download site is so confusing. Which files does one download? Then how to add a Flex plugin to Eclipse? Where is the Flex plugin. You do not tell how to get these files!

Berna's Gravatar Do you know if instructions for plugin of Flex builder 3 are the same as these ones?

Shilpa Desai's Gravatar Hello,
I have Eclipse 3.2.2 and i am trying to intergarte plugin of Flex 3. So can u giide me which plugin required and also where the mxml.xsd file is present?

Please reply this......

Shilpa's Gravatar thnx for mxl.xsd help. Now i am little bit confused about how to crate new project in eclipse about flex...if you have any link or tutorial please suggest me

Shilpa's Gravatar Hi,

I am tryig to run my project using Ant build (apache-ant-1.7.1-bin.zip) with flex 2 sdk and eclipse 3.2.2. But it throwing one error like below
:
:[exec] Loading configuration file C:\Program Files\flex_sdk_2_194515\frameworks\flex-config.xml

[exec] Error: unable to open 'Workspace\Flex\test.mxml'

[exec] Use 'mxmlc -help' for information about using the command line.

BUILD FAILED
D:\Flex Workspace\Flex\build.xml:5: exec returned: 1

Ant build is running as i have tested from command prompt.
Please suggest me why this error is coming?????

akhil agrawal's Gravatar i got web and xml entry but it is not displaying anything for xmlcatalog in right pane what should i do?? so that i can set the user entries for xml catalog

shruthi C's Gravatar Hi...I am basically trying to set up eclipse 3.5 for Flex 3 SDK, and I have been successful in downloading both of them on my MAC.
I am having a difficulty in figuring out the latest / exact versions of the four plugins (emf,gef,jem,wtp as mentioned in this post) to be installed.It would be great if I could get help regarding this....
Please reply

saheb's Gravatar I have eclipse 3.4.1. I have downloaded all the zip files mentioned
above but i still dont get the Flex perspective. Please help