Access Keys:
Skip to content (Access Key - 0)

Setting Up Eclipse

When you work with Mule, you can make configuration and development much easier by using an IDE. This page describes how to set up Eclipse, an open-source IDE, to enable easy configuration of Mule and development of new functionality. This page describes using Eclipse 3.4 (Ganymede), which you can download here (download the Eclipse IDE for Java EE Developers).

Before you continue, be sure you have installed Mule and the prerequisites as described in Installing Mule. You must also have Internet access to build the example application and generate the Eclipse project, as each of those steps downloads dependencies.

Build the Hello Application

The first step is to build the application you want to work with in Eclipse. This will download the dependencies in preparation for generating an Eclipse project. For the sake of illustration, we will build and import the [Hello example] application into Eclipse.

To build the example, navigate to the MULE_HOME\examples\hello directory, and then type mvn at the command prompt.

Generate the Eclipse Project

After building the Hello application, you can generate the Eclipse project by typing the following command:

mvn eclipse:eclipse

You can now configure Eclipse and import the project.

Configure Eclipse

You only need to configure Eclipse once. With subsequent projects, you can skip these steps.

  1. Start Eclipse.
  2. In the Workspace Launcher, specify the location of the examples directory under your Mule home directory (such as C:\mule\examples), and click OK.
  3. Click the Workbench icon on the right to display the workbench.
  4. Choose Window > Preferences.
  5. Expand Java in the navigation tree, click Compiler, and then change the compiler compliance level to 1.5.
  6. Click Installed JREs. If the JRE is not version 1.5, click Edit, click Directory and navigate to your JDK1.5 directory, and then change the JRE name to jdk5. Click Finish, and then click OK.
  7. When prompted to rebuild, click No.

Import the Eclipse Project

  1. In the Workbench window of Eclipse, choose File > Import.
  2. Expand General, click Existing Projects into Workspace, and then click Next.
  3. In the Import dialog box, click Browse, navigate to the Mule examples directory again, and click OK. The hello project should be listed and selected.
  4. Click Finish.

The hello project is now listed in the Project Explorer on the left. You will notice some errors at the bottom of the screen, which are caused by your build path needing to be configured.

Configure the Eclipse Build Path

You only need to take these steps once. Future Mule projects will use the same build path.

  1. In the Project Explorer, right-click the hello project and choose Build Path > Configure Build from the popup menu.
  2. In the Properties dialog box, click the Libraries tab, and then click Add Library.
  3. Click User Library and click Next.
  4. Click User Libraries, and then in the Preferences dialog box, click New.
  5. In the New User Library dialog box, enter MULE_LIB and click OK.
  6. Click Add JARs, navigate to the \lib\mule directory under your Mule home directory, select all the JARs, and click Open.
  7. Click OK and then Finish.
  8. Click Add Variable, click Configure Variables, and then in the Preferences dialog box, click New.
  9. In the New Variable Entry dialog box, create a variable called M2_REPO that points to your Maven repository (such as C:\.m2\repository), which you created when you installed Maven. Click OK.
  10. In the Preferences dialog box, click OK, and this time when you're prompted to rebuild, click Yes. Click OK in the open dialog boxes to close them and rebuild the project.

Create a Run Configuration and Run the Application

This step defines your configuration settings. You only have to do this once per project, and thereafter your settings are stored and used each time your run the application.

  1. Choose Run > Run Configurations.
  2. In the left window, double-click Java Application, and then change the name to hello and specify org.mule.MuleServer for the main class.
  3. Click the Arguments tab, and then enter -config conf\hello-config.xml (For Windows) or -config conf/hello-config.xml (For Linux/Unix) in the Program Arguments box.
  4. Click Apply and then Run.
    The Hello application runs in the Console tab at the bottom of the window, prompting you to enter your name. You can type your name and press Enter to see the application continue.

Congratulations! You have successfully built and run your first Mule example from within Eclipse. You can now add services to the configuration, write POJOs as needed, debug your code, and compile and run your examples all within the IDE. For a tutorial showing how to add functionality to a configuration, see the Tutorial.

If you want to import another example into Eclipse, follow the instructions on this page to generate an eclipse project for that example, import the project into the workspace, and then just run the example by choosing Run > Run. You do not have to repeat the steps for configuring Eclipse.

<< Previous: Running Mule Next: Examples >>
Adaptavist Theme Builder (3.3.2-conf2.10) Powered by Atlassian Confluence 2.10, the Enterprise Wiki.
Free theme builder license