Lab: Environment Setup on Your Own Computer

This document will guide you through the various steps needed to set up the programming environment for CSE 2221/2231 on your own computer. With only minor modifications these steps will work equally well on all popular operating systems (Linux, Mac OS X, and Microsoft Windows). The screen shots included here are all taken on a Windows platform, but they should be very similar to what you'll see on different systems.

This document has been designed with a specific sequence of steps for you to follow. Hover over the thumbnails to see the full-size screen shots. You can also click on a thumbnail to open the full-size screen shot in a separate window/tab. If you have any questions or run into any trouble, ask an instructor for help and try to provide as much detail about what you have done, what you have observed, and what the problem is.

It is very important that you follow the instructions carefully and pay attention to the details. Make sure you do not skip any steps and that you type all inputs exactly as they are provided in this guide (including spelling and capitalization).

Downloading CSE 2221/2231-Specific Files

The following files are customized and specific to CSE 2221/2231.

  1. Download OsuCseWsTemplate.zip, expand (uncompress, unzip) it in an easily accessible location you can remember (e.g., under Windows you could expand it in the My Documents folder). This ZIP archive contains a folder named workspace configured for SW I & II. You will store all your Eclipse projects in this folder.
  2. Download components.jar, place it in an easily accessible location you can remember (e.g., under Windows you could put the components.jar file in the My Documents folder), not inside the workspace folder you extracted from the ZIP archive in the previous step.

You will also need to download and install a recent distribution of the Eclipse IDE (Integrated Development Environment). Note: An installation of a recent Java Development Kit (JDK) is no longer necessary.

If you already have an installation of Eclipse and the needed plugins from a recent offering of CSE 2221/2231, you can skip directly to Final Touches. But first make sure to read the important note here.

Downloading and Installing Eclipse

You need to download a recent release of Eclipse. If you already have Eclipse installed from a previous class that was not CSE 2221/2231 (e.g., from CSE 1223), you need to reinstall Eclipse following these steps. The version you have is probably not the correct one and it is missing the needed plugins.

In your browser, go to Eclipse Downloads. Do not use the Eclipse Installer. Instead follow these steps to download and install Eclipse.

Find the Eclipse IDE for Java Developers package (make sure you do not pick the wrong package) and click on the appropriate download link for your operating system (Windows, Mac, or Linux) and architecture (32-bit or 64-bit). There are many other packages but this is the one that you'll need in this class.

Once the download has completed, locate the downloaded file. This file will be a compressed (i.e., a ".zip", or ".tar.gz") file. Uncompress this file into the directory of your choice. It doesn't really matter where you put the Eclipse installation folder as long as you know how to retrieve it. You can optionally create a shortcut of the Eclipse IDE executable file ("eclipse.exe" on Windows, or "eclipse" on Linux, or "Eclipse" on Mac OS X) found in the directory that is created. To start Eclipse you just double-click on the executable file or the shortcut, but...

IMPORTANT! Do not start Eclipse yet and read this section carefully before proceeding with the rest of the set-up. When you start Eclipse for the first time, it is going to ask you to specify a folder for your "workspace". That's the folder where Eclipse will store all your work (e.g., your Java programs). You must enter the location on your disk of the workspace folder you downloaded earlier (OsuCseWsTemplate.zip) . If you don't or if you provide the wrong location, Eclipse will silently create a new empty workspace. If that happens, you have to switch to the correct workspace. There is no way of "fixing" a default empty workspace to behave like the one we use in the class.

It is easy to check whether you have opened the correct workspace. Eclipse window should look like thisEclipse IDE workspace window on Windows showing the Package Explorer and Problems views. Left pane labeled Package Explorer lists a single project entry ProjectTemplate. Large central editor area is empty. Bottom pane labeled Problems shows the summary line 2 errors, 1 warning, 0 others and list entries Errors (2 items) and Warnings (1 item). Window title bar reads workspace - C:\Users\jesse\Documents\workspace - Eclipse IDE.. Specifically, if you do not see ProjectTemplate in the Package Explorer tab on the left of the window (or you see additional projects), you did not open the correct workspace. If the workspace does not look right, you can switch to the correct one by selecting, in Eclipse's menu, File > Switch Workspace > Other... and then navigating to the correct workspace folder on your disk.

One last important note before we proceed. If you already have a workspace from a previous class (any class, including CSE 1223 and CSE 2221/2231), you must start with a new clean workspace from the template. Do not reuse workspaces across classes.

Downloading and Installing Plugins

The functionality of the Eclipse IDE can be expanded by adding extensions known as plugins. You'll need to install four such extensions: Checkstyle, SpotBugs, Subclipse, and Eclipse Web Developer Tools.

To install new plugins you need to start Eclipse. The first thing Eclipse needs to know is where you want to store your work (e.g., your Java programs). Eclipse calls this directory a workspace. Enter the location on your disk of the workspace folder you downloaded earlier. You may click on the checkbox Use this as the default and do not ask again, if you want Eclipse to open this workspace every time you run it. Then click OK.

Thumbnail for Screenshot026a.png Eclipse workspace selection dialog showing a Workspace text field containing a file path, a checkbox labeled Use this as the default and do not ask again, and OK and Cancel buttons; underlying Eclipse IDE window visible in the background

Once Eclipse is finished loading, it will open the window where you will usually find yourself from now on when you start Eclipse. A reminder, again, that if you do not see ProjectTemplate in the Package Explorer tab on the left of the window, you did not open the correct workspace.

Thumbnail for Screenshot028a.png Eclipse IDE workspace window on Windows showing the Package Explorer and Problems views. Left pane labeled Package Explorer lists a single project entry ProjectTemplate. Large central editor area is empty. Bottom pane labeled Problems shows the summary line 2 errors, 1 warning, 0 others and list entries Errors (2 items) and Warnings (1 item). Window title bar reads workspace - C:UsersjesseDocumentsworkspace - Eclipse IDE.

Let's install the Checkstyle, SpotBugs, Subclipse, and Eclipse Web Developer Tools plugins.

  1. Select Install New Software... from the Help menu at the top of the window.

    Thumbnail for Screenshot004.png Install New Software dialog showing Add button and repository list

  2. Now you need to create a new software site to tell Eclipse where to find the first plugin. Click the Add... button at the top-right of the window.

    Thumbnail for Screenshot005.png Add Repository dialog with Name and Location fields for a plugin site

  3. In the dialog, for the Name enter Checkstyle and for the Location enter https://checkstyle.org/eclipse-cs-update-site/. Click Add.

    Thumbnail for Screenshot006.png Eclipse Install list showing Checkstyle repository entry with Eclipse Checkstyle Plug-in selected

  4. Once the installer is done looking up the new site, it will display a list of the plugins available. Select only Eclipse Checkstyle Plug-in from the Checkstyle entry. Click Next.

    Thumbnail for Screenshot007.png Install review screen confirming Eclipse Checkstyle Plug-in selection

  5. Eclipse allows you to review your selection and to confirm you are installing the Eclipse Checkstyle Plug-in. Click Next again.

    Thumbnail for Screenshot008.png License agreement dialog with I accept the terms option for plugin installation

  6. In the next window, check the I accept the terms of the license agreement radio button and click Finish.

    Thumbnail for Screenshot009.png Eclipse plugin installation progress dialog showing progress bar and installation details

  7. Eclipse displays its progress with the plugin installation.

    Thumbnail for Screenshot010.png Eclipse plugin installation progress details listing files being installed

  8. Next you should get a security warning. If you want, you can look at the details, but this warning is expected and you should click Install anyway.

    Thumbnail for Screenshot011.png Security warning dialog offering Install anyway action during plugin installation

  9. Finally the installation of the Checkstyle plugin is complete and Eclipse offers to restart itself. Normally you would want to say yes, but in this case, since you need to install a couple other plugins, click No.

    Thumbnail for Screenshot012.png Plugin installation complete dialog prompting whether to restart Eclipse

  10. Let's move on and install the SpotBugs plugin. Repeat steps 1 and 2 above (select Install New Software... from the Help menu, then click the Add... button). In the Add Repository dialog, enter SpotBugs for the Name and https://spotbugs.github.io/eclipse/ for the Location. Click Add.

    Thumbnail for Screenshot013.png Add Repository dialog for SpotBugs showing Name and Location fields

  11. Select the only plugin available, SpotBugs, from the SpotBugs entry. Click Next.

    Thumbnail for Screenshot014.png Install New Software view with SpotBugs plugin selected

  12. Repeat steps 5-9 above: confirm you are installing the SpotBugs plugin, accept the license agreement, get past the security warning, and, once more, click No when the installation of the SpotBugs plugin is complete and Eclipse offers to restart itself again.

    Thumbnail for Screenshot012.png Plugin installation complete dialog prompting whether to restart Eclipse

  13. Next we'll install the Subclipse plugin. Repeat steps 1 and 2 above (select Install New Software... from the Help menu, then click the Add... button). In the Add Repository dialog, enter Subclipse for the Name and https://subclipse.github.io/updates/ for the Location. Click Add.

    Thumbnail for Screenshot073.png Add Repository dialog for Subclipse showing Name and Location fields

  14. You should see several folders, but we are only interested in two: Core SVNKit Library (required) and Subclipse. To avoid issues later, make sure you select only the following features: in the Core SVNKit Library (required) folder select SVNKit Library (it should be the only entry); in the Subclipse folder select only the two entries Subclipse and SVNKit Client Adapter. Before you click Next double-check in the screenshot below that you have selected the correct entries and only those entries.

    Thumbnail for Screenshot074.png Install New Software selection with Core SVNKit Library and Subclipse features selected

  15. Repeat steps 5-9 above: confirm you are installing the Subclipse plugin, accept the license agreement, get past the security warning, and, once more, click No when the installation of the Subclipse plugin is complete and Eclipse offers to restart itself again.

    Thumbnail for Screenshot012.png Plugin installation complete dialog prompting whether to restart Eclipse

  16. Finally you are ready to install the last plugin, Eclipse Web Developer Tools. Again select Install New Software... from the Help menu. This time, however, there is no need to add a new site. Click on the drop-down menu to the left of the Add... button and select the 20??-?? - https://download.eclipse.org/releases/20??-?? site. (This entry's name depends on the specific release of Eclipse you are running. The '??' are just placeholders that should be replaced by the correct numbers of your release.)

    Thumbnail for Screenshot016.png Eclipse release site selection list showing the releases update site selected

  17. Go to the bottom of the list of available plugins and expand the last entry Web, XML, Java EE and OSGi Enterprise Development.

    Thumbnail for Screenshot017.png Plugin list with Eclipse Web Developer Tools entry visible and highlighted

  18. Scroll down until you find the Eclipse Web Developer Tools plugin and select it. Make sure you don't accidentally select some other entry with a similar name. Click Next.

    Thumbnail for Screenshot018.png Eclipse Web Developer Tools entry selected in Install New Software dialog

  19. Repeat steps 5 and 6 above: confirm you are installing the Eclipse Web Developer Tools plugin and accept the license agreement. Once the installation of the plugin is complete Eclipse offers to restart itself yet again. Now click Restart Now.

    Thumbnail for Screenshot019.png Restart now prompt after installing Eclipse Web Developer Tools

This completes the installation of Eclipse and the necessary plugins.

Final Touches

There are still a few things that need to be taken care of to complete the setup. First we need to fix a few Eclipse settings. Access the preferences window by selecting Preferences from the Window menu (on Mac OS X, use Settings... under the Eclipse menu).

Thumbnail for Screenshot030.png Eclipse Preferences window showing navigation tree and preference panes
  1. Next select Java > Installed JREs.

    1. Click on the default selection (the one with the checkmark), and click Edit...

      Thumbnail for Screenshot044.png Installed JREs dialog with a JVM entry selected

    2. Then enter -enableassertions (or simply -ea) in the box labeled Default VM Arguments and click Finish.

      Thumbnail for Screenshot045.png Default VM Arguments dialog with -enableassertions (-ea) entered

    3. Then click Apply (not Apply and Close).

      Thumbnail for Screenshot045a.png Thumbnail of Installed JREs default VM Arguments dialog

  2. Expand and select Java > Build Path > Classpath Variables.

    1. Select the OSU_CSE_LIBRARY entry and click on Edit...

      Thumbnail for Screenshot034a.png Thumbnail of Build Path Classpath Variables dialog

    2. Set the Path to the location of the components.jar file, either by simply typing it in or by clicking on File... and navigating to the appropriate location of the file on your file system. Click OK

      Thumbnail for Screenshot035a.png Thumbnail showing components.jar path set in dialog

    3. Click Apply and Close and when asked whether you want to do a full build now, click Yes.

      Thumbnail for Screenshot035b.png Thumbnail of Build Path Classpath Variables dialog

If you followed all the steps above correctly, everything should now be set up properly and there should be no errors or warnings in the given ProjectTemplate . (Actually there could be one warning that the compiler compliance specified is 1.7 but a different JRE is used. That is okay.)

Creating a New Project from a Project Template

Work inside a workspace is organized in projects. A project is essentially a folder (usually inside the workspace folder) where you can store your code, documentation, tests, and all kinds of resources related to a given task.

The workspace already contains a project named ProjectTemplate as you can see in the Package Explorer view. You can expand a few entries to see what kind of structure this project has.

Thumbnail for Screenshot062.png Eclipse Package Explorer showing ProjectTemplate project selected

Although you can create projects directly in Eclipse, to avoid having to spend time customizing each project, you will create new projects by simply copying and pasting the template in Eclipse any time you need a new project (as explained below).

Important: You should never modify this template project! If you do accidentally modify it, or think you might have done so, you should see your instructor who will help restore the original project structure.

Whenever you need to create a new project, e.g., for a lab or closed lab assignment, you copy and paste ProjectTemplate by following these simple steps:

  1. In the Package Explorer view, click the right mouse button with the mouse pointer on the ProjectTemplate project entry and select Copy from the pop-up menu.

    Thumbnail for Screenshot063.png Context menu showing Copy on ProjectTemplate project in Package Explorer

  2. Click the right mouse button anywhere in the Package Explorer view and select Paste from the pop-up menu.

    Thumbnail for Screenshot064.png Paste option available in Package Explorer context menu for pasting a project

  3. Enter the name for your new project, MyProject, and click OK.

    Thumbnail for Screenshot065.png New Project dialog with MyProject entered as project name

  4. Your new project is now displayed in the Package Explorer ready to be used as the starting point for your assignment.

    Thumbnail for Screenshot066.png Package Explorer showing the newly created MyProject ready for use

This completes this Eclipse setup guide.