Hi There!

I'm Dan Schlegel, an Assistant Professor in the Computer Science Department at SUNY Oswego

Development Environment Configuration

What follows is the recommended and supported development configuration used in our class. Note that you may also choose to set up a development environment on your local machine by following these directions for Windows. A subset of these instructions will work for personal Debian-based Linux installs, and only minor variations are needed for Mac (use brew to install the various components, and I recommend Aquamacs instead of plain Emacs). We won’t be able to support issues which arise on your local machines, though the student members of the CSA who often congregate in 425 may be willing to help.

The configuration assumes you are either using one of the NUCs in the lab locally, or are remotely accessing the CS server called pi. In order to remotely access pi, do the following. If you are in the lab you can skip to the section on Software Configuration.

Accessing pi from your personal computer

Windows

  1. If you would like to use visual applications (such as the visual version of Emacs) install and run VcXsrv, an application which will allow you to use remote graphical Linux applications on Windows. While Emacs works quite well this way even from off campus, some other graphical applications are extremely slow this way. Note that Emacs also has a text-only version which runs from the terminal without a graphical interface.
  2. Download PuTTY if you do not have it already.
  3. Run PuTTY and enter the following:
    Host​ ​Name:​ pi.cs.oswego.edu
    If you’re planning to use visual applications, on the left side under Connection, expand the SSH item, then choose X11. Check the “Enable X11 forwarding” option.
  4. click the “Open” button at the bottom of the window.

Enter your lab username and password when prompted. If you are prompted about an RSA key type ‘yes’.

You should now be connected to the pi server.

Mac

If you plan to use visual applications, such as the visual version of Emacs, install and run XQuartz. Then, follow the below Linux instructions.

Linux

  1. Open a terminal
  2. At the prompt, type:
Be sure to replace YOUR_USERNAME with your actual username. If you are not using visual applications you may exclude the -X argument.

Enter your lab username and password when prompted. If you are prompted about an RSA key type ‘yes’.

You should now be connected to the pi server.

Software Configuration

Most of the required software is already installed, we only need to make some minor additions and do some configuration.

If you do not already have an open terminal, open one. Then run emacs by typing the following into your terminal (note that lines beginning with # are comments):

Note: The following instructions will assume you are using the graphical version of emacs. It’s perfectly possible to use the text-based version in the terminal, but you’ll need some more key commands to move around the window.

In the emacs window, press the Ctrl and x key, followed by Ctrl and f key. This is usually annotated as:

The result of this is to tell emacs you would like to open a file. At the bottom of the window (in the minibuffer) it will say “Find file: ~/”. At this prompt type:

and press enter (be sure you include the period at the beginning of the file name!). What will load will likely be a blank file, but it may contain some text. Add the following to the top of the file:

This adds a repository to the package manager in emacs.

Save the file by hitting C-x, C-s. Then, exit emacs (C-x, C-c) and restart it.

Once emacs restarts, type:

The M-x means “Meta and the x key” where the meta key is usually the Alt key on most keyboards (Option on Mac keyboards).

A list of packages will be displayed. Scroll down to JDEE and click on it. Choose to install it. JDEE will give us Java syntax highlighting and auto-indenting.

Your build environment is now configured!

Configuration Testing

In your second terminal create a new folder called csc241 in your home directory, and inside that a new folder called testproject. Then navigate into testproject.

We will be using Gradle to handle the configuration of our Java projects. This will allow us to easily compile the project and to integrate plugins into the build process. We’ll be using the Error Prone plugin which will force you to avoid some coding mistakes which Java might otherwise not complain about.

In emacs, open the (new) file ~/csc241/testproject/build.gradle

This file will contain the configuration for the project.

In your build.gradle, add the following:

This tells Gradle to use Java to build this project, and to use the Error Prone plugin. Save the file.

Gradle expects to find your source code under src/main/java, so make those directories in the terminal. Then, open the file ~/csc241/testproject/src/main/java/Main.java in emacs.

Create a “hello world” style program in that file and save it.

Back at your terminal, type

Gradle will then build your project. (Note you can see the other things you can ask Gradle to do by running gradle tasks.)

Now, assuming you had no errors you need to fix, change into the ~/csc241/testproject/build/classes/java/main directory and run

Your program should run.

You can verify that Error Prone is working by adding something silly to your code, such as in the following example:

Even though this is completely valid Java code, Error Prone no longer allows it to compile.

Provided all of this works, you should be ready to start programming!