Lab: Setting Up Your Personal Development Environment
CS350, Summer 2022
1 Overview
- Get (re?)-acquainted with the Eclipse and/or VSCode IDE.
- 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
- a Java compiler, with debugger & associated tools
- The
git
version control system, though you can wait to install that for a while. - an IDE that can aid in Java development and that
- support for working with version control systems such as
git
. - support for building with
gradle
git
andgradle
yet (though, as of Summer 2021,git
is now covered in CS252) - support for working with version control systems such as
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:
- If you have a good PC, this is fast and responsive.
- You don’t need a good Internet connection. You may not need to be on-line at all.
Disadvantages:
- If your PC is slow, your tools will be sluggish.
- There’s lots of software to install on your PC, taking up a good chunk of your hard drive.
- If your operating system is different than the one used by the instructor, your compiled code may behave differently for you than it does for your instructor.
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:
- If you have a good Internet connection, this is fast and responsive (usually even if your PC is slow).
- You don’t need to install much on your PC – X2Go will do (and you should already have that from CS252).
- By running on the same CS machines that your instructor is likely to use, you avoid problems of compatibility when your code is graded.
Disadvantages:
- If your Internet connection is slow, everything will feel sluggish and unresponsive.
- If your Internet connection is down, you can’t work at all.
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:
- If your PC is slow, this will still feel reasonably fast and responsive, because most of the CPU-intensive tasks are done remotely.
- If your Internet connection is slow, this will still feel reasonably fast and responsive, because the amount of information being transferred is relatively small.
- There’s less software to install on your own PC than in local development.
Disadvantages:
- If your Internet connection is down, you can’t work at all.
- There are extra steps involved in starting each work session and in the initial setup of your project.
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…
- Install the Java compiler & tools on your own PC.
- Install your choice of Eclipse or VSCode on your PC.
- Install
git
on your own PC (optional but recommended).
2.3.2 If you want to do remote display…
-
Run X2Go on your own PC.
(Presumably, you have this in place from CS252.)
-
Run the Java compiler, Eclipse IDE, &
git
on the CS Linux servers.
2.3.3 If you want to do remote development…
- Use the Java compiler & tools and
git
on the CS Linux server. - Install VSCode on your PC.
-
Configure VSCode to use SSH connections to the CS Linux servers to edit, compile, and run your programs.
-
2.4 Once You’ve Made Your Choice
-
If you are doing local development, install the Java Development Kit (JDK), version 11 or later.
- For Windows, get it from Oracle
- For MacOS, follow these instructions
- For Ubuntu and similar Linux distributions, do
sudo apt-get update sudo apt-get install default-jdk
-
If you are doing local development, and have opted for the Eclipse IDE, get it here.
-
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.
- Install the
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)
-
Return to CS252 and re-complete the two Eclipse-oriented Try This exercises in IDEs & Remote Display and Debugging in IDEs.
-
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:
- What Operating System (OS) are you using?
- What have you already installed? What are the versions?
- 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.
-
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++. -
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. -
Run the program. Test data is provided in the
testData/
directory, and theREADME
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 selectingRun as...
to set up a Run configuration. - For VSCode users, you will select
Add Configuration...
from theRun
menu. - In both IDEs, you will want to include the path to one of the test data files as a command-line argument.
- For Eclipse users, that means right-clicking on
-
Set a breakpoint at the line containing the
subtract
call in functiondoIt()
inHighway.java
. Run the program in the IDE’s debugger. -
When execution stops at your selected breakpoint, use the IDE to show the current value of the variables
covered
andgaps
.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.
-
Step over the line containing the
subtract
call and examine how the value ofgaps
has changed. - Stop the debugger. In the
Interval.java
file, comment out the functiontoString
. Restart the debugger and examine the variablescovered
andgaps
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 atoString
function even if it is not an “official” part of the class interface – having a gooftoString
function is a major convenience when debugging.