Skip to main content
Jump to: navigation, search

E4/SWT/Running the demos

< E4
Revision as of 17:48, 6 February 2009 by (Talk | contribs)

These instructions assume that you have already downloaded and installed the SWT ActionScript development tools. If you have not, please follow these directions before continuing.

The SWT port for Flex consists of the Adobe Flex environment (the ActionScript compiler), the SWT ActionScript development tools plugins (which provides the tools needed to build, launch and debug Java code in a Flash player) and the Eclipse target environment (the running plugins, the SWT port itself and example code). NOTE: That the both the tools and the port are in the pre-alpha stage. You are living on the bleeding edge. Good luck!

Setup Flex environment:

  1. Download and install the Adobe Open Source Flex SDK (available from NOTE: The path where you install the Flex SDK must contain no spaces. This is due to a bug in FCSH.
  2. Verify that your Flex install works by opening a command prompt, changing to the Flex SDK bin directory, typing "mxmlc" and hitting Enter. If you get a message like the following, you will need to add a JAVA_HOME environment variable that points to the home dir or edit the bin/jvm.config file in the Flex SDK.
  Error: could not find JRE
  Error: could not find Java 2 Runtime Environment.

Setup the Flex tools:

  1. Shut down the Eclipse build which has the SWT ActionScript tools installed. If you do not have an Eclipse build with the SWT ActionScript tools already installed, follow these directions before continuing.
  2. Update your eclipse.ini file and add another line at the end, -Dflex.sdk=<your path to the installed sdk> Note: Make sure you don't edit the command line (for example in a launch shortcut) as it overrides the .ini file and loses the Flex settings.
  3. Make sure that you are using at least a 1.5 JRE to run Eclipse as the ActionScript tools plugin requires it.
  4. Create a new Eclipse Workspace. NOTE: The path were you create the workspace must contain no spaces. This is due to a bug in FCSH.
  5. Create a workspace variable in Linked Resources preference page ('Preferences' -> 'Workspace' -> 'Linked Resources'). The variable should be called WORKSPACE and point to the root of your Eclipse workspace.

Setup the Eclipse target environment

  1. Turn off auto build ('Project' -> 'Build Automatically')
  2. Download the SWT source zip from the latest download page (The zip is named org.eclipse.swt.e4.flex-I[timestamp].zip).
  3. Import this zip into your project ('File' -> 'Import' -> 'General' -> 'Existing Projects into Workspace' -> 'Select archive file').
  4. Connect to and browse to the e4 project. Check out the org.eclipse.e4.swt.releng project into your workspace.
  5. Select the "", right click and select Import Project Set... (If prompted for username:password, you should use anonymous:anonymous).
  6. Add a new ActionScript VM. ('Window' -> 'Preferences' -> 'Java>Installed JREs').
    1. Click Add...
    2. Select ActionScript VM, click next.
    3. Click Directory... and browse to either your Firefox or IE install directory.
    4. Click OK.
    5. Click Finish
  7. Change the .classpath_flex to .classpath for the following projects. (Note that in order to see the classpath files, you have to either do this in the Navigator view or turn off the resources filter in the Packages Explorer by clicking on the drop down arrow menu in the top right hand corner of the package explorer, selecting Filters and unchecking *.resources).
    1. org.eclipse.swt
    2. org.eclipse.swt.e4.jcl
    3. org.eclipse.swt.examples
  8. Refresh the org.eclipse.swt project to pick up the linked resources.
  9. Turn on Build Automatically (You can watch the build progress in the ActionScript Build Console, available from the Console view)
  10. You can run any of the demos from org.eclipse.swt.e4.examples by clicking on them and Selecting "Run As>ActionScript Application". Note that for the Flickr example, you must select static linking in the launch configuration dialog.

Setup a sample SWT ActionScript project from scratch

 Note that this assumes you have gone through the steps above.
  1. Create a Java Project.
  2. Add the ActionScript nature to the project "Select Project>Popup Menu>Action Script Tools>Toogle Nature".
  3. Add the org.eclipse.swt project to the Java Build Path projects tab.
  4. Change the execution environment of the project JRE container to J2AS-1.5
  5. Add this class, save and Run as ActionScript Application
public class Main {
	public static void main(String[] args) {
		Display display = new Display();
		Shell shell = new Shell(display);
		shell.setLayout(new GridLayout(1, false));
		Button b = new Button(shell, SWT.PUSH);

Back to the top