JavaLib
 
Conversions
 
Overview
Eclipse
NetBeans
Command
BlueJ
 
Downloads
 
TSRJ Home
TSRJ Local

Eclipse

  • Eclipse IDE requires that you designate a specific directory for its workspace. Eclipse uses this directory to keep all the source files for your projects, all information about each of your project, the documentation for each project, and more. Set up the directory .../EclipseWorkspace for this purpose.

  • Also create a directory .../EclipseJARs where you will save any libraries your projects may need. Do this before you start the Eclipse for the first time.

  • Download the Eclipse from the XXX website and follow the instructions to install the software

  • Save the ProfessorJ program you want to run in Eclipse, say in the directory .../ProfJPrograms. Assume the file name is books-authors.java

  • Download the file ConverterEclipse.zip into a temporary directory (e.g. .../tmp and unzip it there

  • Download the file MyProjectEclipse.zip into a temporary directory (e.g. .../tmp and unzip it there

  • Download the file tester.jar into the .../EclipseJARs/Libraries directory

  • Start the Eclipse application

  • When it asks you to select the workspace locate your .../EclipseWorkspace directory

  • .... set up the workspace with the Project and Outline, etc.

  • In the File menu choose Import... then select Existing Project into Workspace and hit Next

  • In selecting root directory browse to find the .../tmp directory where you have saved the ConverterEclipse and MyProjectEclipse

  • Select both projects, check the Copy projects into workspace and hit Finish

  • You are now ready to convert the ProfessorJ program to Java 1.5 and to run it

  • Click on the triangle to the left of the ConverterEclipse project in the Package Explorer frame, then right click on the triangle left of src and again, on the triangle to the left of <default package>

  • Double click on the file name Converter.java and the file should open in the central frame of the workspace.

  • Click on the left green triangle in the top left menu bar (the tooltip should say Run Converter.java)

  • The file dialog will ask you to select the ProfessorJ file you wish to convert. Choose the file books-authors.java

  • Next it will ask you to choose the location and the name of the file you want to Save as Java 1.5 File. Choose books-authors-eclipse.java in your temporary directory .../tmp/books-authors-eclipse.java

  • You are almost ready to run your program in Eclipse. Click on the triangle to the left of the MyProjectEclipse project in the Package Explorer frame, then right click on the triangle left of src

  • Highlight src, right click then select Import...

  • Under General select File System (it is probably already selected) and hit Next

  • Browse to your .../tmp folder and select the file .../tmp/books-authors-eclipse.java then hit Finish

  • The file should now appear within the src tab of MyProjectEclipse

  • Now you need to add the tester library to your project. Right click on the MyProjectEclipse and select Properties at the bottom of the long menu

  • On the left hand side select Java Build Path.

  • On the right hand side select Add External JARs...

  • Browse to locate your tester.jar file in the .../EclipseJARs/Libraries directory

  • Select OK on the bottom right.

  • Your program is almost ready to run. Double-click on the file books-authors-eclipse.java and it will open in the main frame of the Eclipse workspace. Scroll through the file to see if there are any remaining problems, before the program can run. Every error is marked in red on both the left hand side and the right hand side, with explanation of the problem when you mouse over the left hand side mark.

  • The only problems we anticipate are the method definitions for methods required when the class implements an interface. By definition all methods defined in an interface are considered to have public visibility and all implementing methods have to match this. Add the word public before the header of every method that is required to implement an interface. You should now be able to run your program.

  • When the file books-authors-eclipse.java is open in the main window of the Eclipse workspace, click on the left green triangle in the top left menu bar (the tooltip should say Run MyProjectEclipse) to run your program. The printout of all fields in your Examples class as well as a report on all tests appears in the Console window on the bottom of the Workspace.

  • If the name of your Examples class is different than just "Examples", maybe you used the name "BookExamples", you need to do one more thing before running your project: Right-click on the name of the project and select Properties at the bottom of the menu choices. Choose Run/Debug Settings in the left frame and click on MyProjectEclipse in the Run/Debug Settings frame. On the right select Edit.

    Under Edit launch configuration properties there is a horizontal menu bar with tabs. The first tab is labeled Main with a green letter ’C’. Move to the next tab to the right, labeled (x) = Arguments and type "BookExamples" into the Program arguments: window.

    Hit Apply then OK then Apply then OK

  • Run the project as before - clicking on the leftmost top green button.