CPSC 327 | Data Structures and Algorithms | Spring 2025 |
Several assignments will involve programming in Java. The tools that you need (Java 17, Eclipse 2024-06) are available on the lab computers in Rosenberg 009 (reboot them to Linux) and Lansing 310 and via the Linux virtual desktop, or you can install them on your own computer.
It is recommended that you use the Linux VDI to access Linux remotely as that simplifies having to copy files across filesystems and means that your files are included in the regular system backups.
If you want to set up your own computer for programming in this course, you will need several things:
You can download Eclipse 2024-06 here — select the "Eclipse IDE for Java Developers" version (not the "Installer") partway down the page and choose the appropriate version for your computer (Mac, Windows, or Linux; choose the x86_64 version unless you have a newer M1 Apple device). While it is recommended that you use this version of Eclipse, things will likely still work fine with a slightly older or newer version.
Eclipse 2022-06 includes Java 17, so you no longer need to download that separately.
You will also need a way to transfer files between your computer and the department filesystem. Using a file transfer program is more convenient than emailing files to yourself, and doesn't require you to remember to transfer the files before leaving the lab. FileZilla is free and runs on all platforms. (You only need to download the client, not the server.) Be sure to check out the documentation (especially the usage instructions). Use csmath-terminal.hws.edu for the host and port 22 when establishing a connection.
Next, configure Eclipse to set certain formatting and coding conventions:
Use the file transfer program to copy the files from /classes/cs327/eclipse on the department filesystem to your own computer.
Create a new workspace directory to use for this course and start Eclipse.
From the "Window" menu, choose "Preferences". On the left side, expand "Java".
Specify how code should be formatted:
Expand the "Code Style" item under "Java", then click "Formatter".
On the right side of the window, click "Import..." and then navigate your way to your copy of cs329-formatter.xml. Select it and click "OK".
Make sure that cs329 is shown as the "Active profile".
Specify options for code generation:
Expand the "Code Style" item under "Java", then click "Code Templates".
On the right side of the window, click "Import..." and then navigate your way to your copy of cs329-codetemplates.xml. Select it and click "OK".
At the bottom of the right side of the window, click the "Automatically add comments for new methods, types, modules, packages and files" box. (It should be checked.)
Tell Eclipse about the convention of naming instance variables ending with _:
Choose the main "Code Style" entry under "Java".
On the right side of the window, click on "Fields" in the box under "Conventions for variable names:" to highlight it, then click the "Edit..." button. In the box that pops up, enter _ (an underscore) in the "Suffix list" box and click OK.
Tell Eclipse to enforce Java 17 syntax rules:
Choose the main "Compiler" entry under "Java".
Set the compiler compliance level to 17.
Tell Eclipse to store compiled classes separately from source files:
Choose the main "Build Path" entry under "Java".
Make sure that the "Folders" option is selected under "Source and output folder", and that the source folder name is src and the output folder name is bin.
Finally, click "Apply and Close" at the bottom of the Preferences window to apply the new settings and close the window.
Note that Eclipse projects store some environment-specific configuration information and Eclipse does some management of the workspace directory on its own, so if you are working on both the CS computers and your own, your best bet for transferring projects is to copy the project folder somewhere other than into your workspace, create a new project within Eclipse on the current computer (if you don't already have one for the program you are working on), and then import the source files from the copied folder to the new project via Eclipse. It's a bit awkward but it gets the job done.
Stop by office hours if you need help with any aspect of getting your computer set up or sorting out the workflow of how you'd actually use all these pieces once they are installed and configured. (Bring your laptop.)