Configuring Eclipse 3.0.1 for Ewe Development

January 13, 2005
www.ewesoft.com

This document describes how to use Eclipse to build and run your Ewe Applications. Eclipse is the recommended IDE for Ewe development and many future Ewe programming tools will be released designed specifically for inclusion into Eclipse.

You should use Sun's latest JDK (the latest J2SE SDK) for compiling and running/debugging your Ewe applications.

Creating a Java Project

This is the essential first step in the process. If you have done this already you can skip over to the next section.

  1. Select File >New >Project...

  2. Under Wizards choose Java Project

  3. Name your project. We will use Solitaire as our example.

  4. Select either Create Project in Workspace or Create Project at external location. This will only affect the location of the directory for the Java and other files used in the project.

  5. Under Project Layout you can choose Use project folder as root for source and class files or Create separate source and output folders. The second option (separate folders) will put your source java files and resources into a sub-directory called src and your compiled classes and other resources into a separate sub-directory called bin within the project directory. This is the recommended option. The first option will place the class files along with the source files directly in the project directory.

  6. Click Next >> to move to the Java Settings part of the Wizard.

  7. Under the Libraries tab click the Add External Jars button. Then locate and select the ewe.jar file on your hard drive.

  8. Then click Finish

You can then begin to create your project or you can copy an old project into the new project directory. In our case we will copy the solitaire directory under the classes directory in the Ewe SDK into the Solitaire directory of the Eclipse Workspace. Then select the Solitaire project in the Navigator window on the left and then right-click Solitaire with the mouse to bring up the context menu. Then press Refresh to tell Eclipse to re-read the project directory to note the new files added.

At this point, Eclipse would normally do a build automatically and any errors will appear in the bottom right of the screen in the Problems tab. The Solitaire project will have a number of Warnings but there should be no Errors.

Configuring the Project to Compile a Ewe Application

If you did step 7 as described above when creating your project, then you do not need to go through this step.

This configures the Project to include the ewe.jar file in the project source path when compiling using Sun's Javac compiler.

  1. Select Project >Properties.
  2. Select Java Build Path on the left.
  3. Select the Libraries tab on the right.
  4. Click on Add External Jars.
  5. Locate and select the ewe.jar file on your hard drive.
  6. Click OK.

From that point all compiling/building will include ewe.jar so your Ewe java files will be able to locate the imported Ewe classes during compile

Configuring the Project to Run/Debug a Ewe Application

This correctly sets up a Run Configuration to run your Ewe application using Sun's Java VM.

  1. Select Run >Run...
  2. Under Configurations (on the left) select Java Application and press New (at the bottom).
  3. Change the Name to be any name you wish - Solitaire would be a good one.
  4. In the Main tab, under the Main class input enter Ewe.
  5. Select the option: Include external jars when searching for a main class
  6. Switch to the Arguments tab.
  7. Under Program Arguments put any of the optional Ewe command line switches (e.g. /s - to emulate a SmartPhone) followed the class name solitaire.Solitaire

Click on Run at the bottom to start the application with this configuration. Thereafter, the normal Run or Debug buttons can be used to run or debug the application using that configuration.

You can always add, delete or modify configurations by again going to Run >Run... at any time.

During debugging you will not be able to step/trace into the classes in the Ewe library (those in the ewe.jar file). In order to do this you should download the Ewe Java source code as provided on the Ewesoft Downloads web page and you will be prompted by Eclipse to Attach Source to the ewe.jar file. When prompted to do so locate and select the Ewe143-JavaSource.zip file. From that point you will be able to debug into the Ewe library itself.

Note that this will use Sun's Java VM to execute your Ewe application. This should run exactly as if run using the native Ewe VM, but you may still wish to use the native VM to test the application as well. The next section describes how to do this.

Configuring the Project to Run a Ewe Application using the Ewe VM

  1. Select Run >External Tools >External Tools...
  2. On the left, select Programs and press New at the bottom.
  3. Under Name put any name you wish, e.g. Ewe Solitaire.
  4. Under the Main tab under Location press the Browse File System button.
  5. Locate the ewe.exe that you installed. By default this will be in C:\Program Files\Ewe
  6. Under Working Directory press Browse Workspace. Then locate the directory under which your compiled classes. By default it will be in the src directory, which is the same directory as your .java source files. However if you configured your project to place the output classes in a separate directory then this will usually be bin.
  7. Under Arguments you place any of the optional Ewe command line switches (e.g. /s - to emulate a SmartPhone) followed the class name solitaire.Solitaire

Click on Run at the bottom to start the Ewe VM running. Thereafter, the normal External Tool button can be used to run this again. You can always add more by going to Run >External Tools >External Tools... at any time.