Java Reference
In-Depth Information
J2SE 7 or later (the latest version is preferred) has been installed and the environment
variable JAVA_HOME has been set to point to the installation folder. For example, on
Windows, JAVA_HOME might be set to C:\ProgramFiles\Java\jdk1.7.0 .
Eclipse 3.7 or later has been installed.
An Eclipse project for j-- can be set up as follows:
1. Unzip the j-- distribution into a temporary folder, say /tmp .
2. In Eclipse, click the File ! New ! Project ... menu 10 to bring up the New Project
dialog box. Select Java Project and click Next. In the New Java Project dialog box,
type \j--" for Project Name, make sure JRE (Java Run-time Environment) used is
1.7 or later, and click Finish. This creates an empty Java project called \j--" in the
current workspace.
3. In the Project Explorer pane on the left, select the \j--" project. Click File ! Import
... menu to bring up the Import dialog box. Under General, select File System as
the Import Source, and click Next. Choose \/tmp/j{" as the From directory, select
\j--" below, and click Finish. Answer Yes to All to the question on the Question
pop-up menu. This imports the j-- les into the \j--" project. Once the import is
complete, Eclipse will automatically build the project. The automatic build feature
can be turned o, if necessary, by clicking the Project ! Build Automatically menu.
To build the j-- project manually, select the project in the Project Explorer window and
click the Project ! Build Project menu. This runs the default ( runCompilerTests ) target
in the Ant file $j/j--/build.xml . To run a different target, edit the following line in the
Ant file:
<projectdefault="runCompilerTests">
and change the value of the default attribute to the desired target.
A.6 Running/Debugging the Compiler
In order to run and debug the compiler within Eclipse, a Launch Configuration must be
created, which can be done as follows:
1. Click the Run ! Run ... menu to bring up the Run dialog box. Select Java Application,
and click the New Launch Configuration button.
2. Give a suitable name for the conguration. Select \j--" for Project and type \jminus-
minus.Main" for Main class.
3. In the (x) = Arguments tab, type appropriate values for Program arguments; these are
the same as the arguments for the $j/j--/bin/j-- script described in Section A.3.1.
For example, type \-t tests/pass/HelloWorld.java" to tokenize the j-- test program
HelloWorld.java using the hand-written scanner.
4. Click Apply and Close.
10 Note that Eclipse menus have slightly different names under different operating systems.
 
Search WWH ::




Custom Search