2.6 Using Eclipse with Nachos

To set up Nachos in Eclipse, we must import the files correctly. This can be a bit tricky as Eclipse has a few settings that need to be configured correctly. Before you begin, ensure that your Nachos folder is inside of another folder, such as 3SH3. If we import the Nachos folder itself then it will not function correctly in Eclipse.

  1. Select File > New > Java Project, and de-select the “use default location” option on the screen, and enter the location of your directory containing Nachos. See Figure  21 for clarification. Click Finish to proceed.

    pict

    Figure 21: Path set to the parent directory of the Nachos folder
  2. Your project directory should now look like Figure  22. Right-click the project name and go to Run As.. > Run Configurations.

    pict

    Figure 22: Eclipse Project Workspace Structure
  3. Under run configurations, you will need to create a new configuration for each assignment. Generally, you only need to change the command line arguments (if they are required by the assignment) and which Nachos project directory the execution will start from. Double click Java Application to create a new configuration.
  4. Under the “main” tab, enter nachos.machine.Machine in the “main class” text box, you can alternatively search for it as well. This will be the main class invoked by Nachos. See Figure  23.

    pict

    Figure 23: Main tab
  5. Now go to the “Arguments” tab, and click “other” in the “working directory” box. In the text box, navigate to proj1 and input it as the working directory. You will change this directory as the assignments progress (i.e. assignment2 will be proj2 and so on), see Figure  24. You can also fill in command line arguments in the top text box if required by the project.

    pict

    Figure 24: Arguments tab
  6. Navigate to the “JRE” tab and ensure that the Runtime JRE is 1.5 or higher.
  7. Run the project, you should have an output similar to Figure  25.

    pict

    Figure 25: Running proj1 in Eclipse
Note: We strongly advise you to use an IDE like Eclipse as it makes debugging and code tracing much simpler.