Please start using Eclipse - an open source Interactive Development Environment (IDE) available free at eclipse.org. Be sure to download the Eclipse Neon release for your computer type (NOT the one for EE developers). If your machine is 64-bit, use that version.
Note: Eclipse is already installed on the Binghamton Unix Lab machines and Unix servers. Please do not try to install your own copy on these machines. If you do so, you will exceed your disk quota.
The following consists of several recommendations and hints on using Eclipse. Start off by opening an Eclipse window. The first time you do this, it will take quite a while because Eclipse needs to initialize itself. Once Eclipse is loaded, select a workspace directory. The cs140 directory is a good choice for this. Then, create a new project using File->New->Java Project. Name the java project cs140. From now on, each lab or assignment can be a new package in the cs140 project.
For our purposes, each lab or assignment you work on will be in a separate package. We will use lab06 as an example for this write-up, but the actual pacakge you will work on may be different.
In the Package Explorer pane of eclipse, right click on the cs140 project, and select New->package on the popup menu. Replace the existing Name: field with the new name of the package... in this case, lab06, and then finish. When you create a new java file in this package, eclipse will automatically add the package lab06; statement to your file for you. You can right click on the package in the Package Explorer pane and choose New->Class to create a new class file.
Occasionally, you will need to read code from a zip file provided to you into a package in Eclipse. In order to do that, first you need to download the zip file so that it is available on your local disk space. Typically, the zip file will be a template for a new package. For instance, if you start with assignment06_template.zip, the implication is that the file contains java code for the assignment06 package.
We are assuming that the zip file contains a sub-diretory which has the package name, and then java files in that sub-directory. All zip files provided to you will have that format. For instance, the assignment06_template.zip file contains a sub-directory called assignment06, and in that sub-directory, there are several java files.
Select the src in the Package Explorer pane, and right click to get a pop-up action window. Select Import... from the popup window to get the Import wizard dialog. Then, expand the General folder, and select the Archive File icon, and then hit the Next> button.
This puts you at the Import Archive file dialog. Click on the Browse... button to the right of the From archive file: field, and select the zip file to import. This will put a folder in the left box that is checked. You can leave this as it is - it will import the entire zip file, or you can expand the folder to select specific sub-folders or files. The Into folder: field should already be filled in to point to the src subdiretory of your workspace. Then, just hit the Finish button.
This will create a new package in the Package Explorer pane, and the Java files (and anything else in the zip file) are now in that package.
Another alternative to unzip your zip file outside of Eclipse, and copy the java files to a package sub-directory of the src sub-directory of your Eclipse workspace. If you do this while Eclipse is already running, then click on the src line, right mouse, and choose the Refresh action to update the Package Explorer pane.
In the Package Explorer pane, select the package you want to export, and right mouse to get actions. Choose Export.... This will bring up the Export resources wizard dialog box.
Expand the General folder, and choose the Archive File icon, and hit the Next> button. This will open the Archive file / Export resource... dialog box.
In the Archive file export dialog box, the left rectangle contains the directories, and the right dialog box contains the list of files that will be included in the zip file. All files in the package should already be selected. You can specify where to write the zip file in the To archive file: field, or you can hit the Browse... button to get a dialog to specify where to write. Typically, for this course, we ask you to save in a file called <userid>_<package>.zip where <userid> is your email userid, and <package> is the package name. For instance, my student e-mail userid is tbarten1. If I wanted to export the assignment06 package, I would write it to a file called tbarten1_assignment06.zip
In the options, choose Save in zip format and Create only selected directories. Then hit the Finish button.
Another alternative is to create the zip file outside of Eclipse. Navigate to the src sub-directory of the workspace, and create the zip file from the package subdirectory. The exact syntax depends on what operating system you are using. For linux, use the command line:
zip -r <userid>_<package>.zip <package>
In Windows, select the pacakge directory in File Explorer, right mouse, and select send to > / Compressed (zipped) folder
This section consists of several hints and shortcuts that may be helpful.