Lab: Setting Up Your Personal Development Environment

CS350, Summer 2022

Contents:

1 Overview

  1. Get (re?)-acquainted with the Eclipse and/or VSCode IDE.
  2. Prepare your personal development environment for the course.

2 Choosing your Development Mode

You are going to be doing a lot of Java programming in this course.

Now is the time, before you actually get involved with the details of an assignment, to decide how you are going to do that and to get everything set up that you need.

2.1 What You Need

You will need an environment that includes

There are two IDEs that I can recommend: Eclipse and VSCode. Both are usable. Eclipse provides a more mature level of support for Java. It also includes an internal implementation of git.

In prior semesters, I have required everyone to use Eclipse, and I do believe that, for the kind of Java work we will be doing, Eclipse provides more complete and more mature support. But VSCode is also acceptable.

You’ll probably find places in the course materials that still assume everyone is using Eclipse, though I am trying tone this down.

In practice, the choice will depend on where you want to work.

2.2 Where Do You Want to Work?

There are three major styles of development environment to consider.

2.2.1 Local Development

Having the IDE and all of the development environment components on your own PC is called local development.

Advantages:

Disadvantages:

2.2.2 Remote Display

In remote display development, we run the IDE, compiler, & debugger on a remote machine (e.g. the CS Linux servers) and have the results displayed on our local PC’s screen via X2Go.

Advantages:

Disadvantages:

This mode of development was a major theme of CS252, so you should already be prepared to work this way.

2.2.3 Remote Development

Remote development strikes a middle point between the extremes of running everything on your PC or running everything on the remote machine.

The compiler and debugger are run on the remote machine and do not need to be installed on your own PC.

The IDE, however, is installed and run on your own PC. It communicates with the remote machine via a combination of SSH and SFTP show you your files on the remote machine, let you edit them, and to issue commands to the compiler and debugger on the remote machine.

Advantages:

Disadvantages:

2.3 Recommendations

If you are unfamiliar with either Eclipse or VSCode, or with the Remote Display and Remote development modes, go back to CS252 and review sections: 4.4 Integrated Development Environments (IDEs), and 4.5 Debugging.

2.3.1 If you want to do local development…

2.3.2 If you want to do remote display…

2.3.3 If you want to do remote development…

2.4 Once You’ve Made Your Choice

  1. If you are doing local development, install the Java Development Kit (JDK), version 11 or later.

  2. If you are doing local development, and have opted for the Eclipse IDE, get it here.

  3. If you are doing remote development, or local development opting for VSCode, install VSCode from here.

    Run it, click on the button to enter the list of extensions.

    • Install the Java Extension Pack.
    • If you are going to do remote development, install the Remote - SSH extension.

3 Learn to Use Your IDE

3.1 VSCode Remote Development

If you are doing remote development, review how to connect remotely with VSCode, section 2.2.1, from CS252.

3.2 VSCode (local or remote development)

Work through this Java in VSCode tutorial, starting at “Getting Started”, skipping over the installation instructions and picking up at “Creating a source code file”., then proceeding through “Navigate and Edit”, “Refactoring”, then Project Management.

3.3 Eclipse (local or remote viewing)

  1. Return to CS252 and re-complete the two Eclipse-oriented Try This exercises in IDEs & Remote Display and Debugging in IDEs.

  2. Do the labs (if you have not already) Java Projects in Eclipse, Refactoring Java Code in Eclipse, and Debugging Java with Eclipse from the CS382 website.

Asking Questions

You will be installing a few different pieces of software. If you run into problems, ask questions.

To answer your questions I will need to know:

  1. What Operating System (OS) are you using?
  2. What have you already installed? What are the versions?
  3. Have you seen unexpected error messages? If so, what are they exactly?

If we are conducting our discussion via email, try include answers to the above (baseline) questions. Doing so will mean that I don’t have to reply simply to ask those same questions, and that will allow me to provide you a more complete initial answer.

If I ask you a question in an email, answer the question. I either need more information or, just as importantly, I am trying to understand your thought process.

4 Practice

Make sure that you can set up a Java project in your IDE, compile and execute the code, and use the debugger.

  1. Download and unzip this code package into a convenient directory.

    Read the README.md file to see what the program does.

    Look briefly through the .java files. Even if you are not yet familiar with Java, you should be able to get a good sense of what they do – the syntax is very similar to that of C++.

  2. Use your IDE to set up a Java project in that directory and compile your code.

    Verify that your code is compiling. You should find .class files corresponding to each of the .java files.

  3. Run the program. Test data is provided in the testData/ directory, and the README explains how to execute the code from the command line. You should be able to extrapolate form that information how to run it from your IDE.

    • For Eclipse users, that means right-clicking on Highway.java and selecting Run as... to set up a Run configuration.
    • For VSCode users, you will select Add Configuration... from the Run menu.
    • In both IDEs, you will want to include the path to one of the test data files as a command-line argument.
  4. Set a breakpoint at the line containing the subtract call in function doIt() in Highway.java. Run the program in the IDE’s debugger.

  5. When execution stops at your selected breakpoint, use the IDE to show the current value of the variables covered and gaps.

    You should be able to see the actual data stored in each of these variables, not just a marker indicating its data type.

    • If execution did not pause at your breakpoint, you probably hav not correctly set up your run configuration to supply the file as a command-line argument. You can confirm this by checking the program output to see if it indicates that data was read successfully.
  6. Step over the line containing the subtract call and examine how the value of gaps has changed.

  7. Stop the debugger. In the Interval.java file, comment out the function toString. Restart the debugger and examine the variables covered and gaps again. Notice how the displayed information has changed.

    You can still get at the internals of the data structures by expanding them in the data display, but the printed summary of a variable’s value is actually supplied by its class’s toString function. This is why most programmers always provide a toString function even if it is not an “official” part of the class interface – having a goof toString function is a major convenience when debugging.