Setting Up Your Personal Development Environment

CS350, Spring 2024

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.

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.

In practice, the choice will depend at least partly 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 to 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

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).

    You should select an LTS (Long-Term Support) version of the compiler. As of when I am writing this, the most recent LTS version is Java 21.

  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.
  4. If you are doing local development, install git on your own PC.

3 Practice Using Your IDE

3.1 VSCode

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

Whether you are doing local or remote development, try working 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”, then “Project Management”, then “Run and Debug”.

Now try the following:

  1. In your operating system, create a directory to hold a Java project.

  2. Run VSCode. From the File menu, select “Open Folder” and navigate to the directory that you just created.

  3. From the File menu, select “New File…”, and create a new file named Hello.java.

  4. Your new Hello.java file should be open in the editor. In the body of the function, enter the code:

    public class Hello {
        public static void main(String[] args) {
            System.out.println("CLI Argument was " + args[0]);
        }
    }
    

    Save the file.

  5. In the right column, right-click on Hello.java and select “Run Java”.

    The program will run, but will complain about an out of bounds error.

    That’s because the program tries to print the first command line parameter (in the array args) and we did not supply any.

  6. From the “Run” menu, “Add Configuration”. A launch.json file will open up. It will contian two run configuraiton, one to lauch your “current file” (whichever Java file you have open in the editor), and one to launch the “Hello” program.

Delete the “Current File” configuration (everything between the { } and the following comma). You should be left with womehting like this:

```

{ // Use IntelliSense to learn about possible attributes. // Hover to view descriptions of existing attributes. // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 “version”: “0.2.0”, “configurations”: [ { “type”: “java”, “name”: “Hello”, “request”: “launch”, “mainClass”: “Hello”, “projectName”: “hello_6684ef8f” } ] } ```

  1. Under the mailClass line, put

    "args": ["Hello world"],
    

    (If we needed more than one command line argument, we could add them within the [ ] as a comma-spearated list.)

    From the Run menu, select “Run without debugging”.

    This time, the program should run correctly.

  2. In Hello.java, Set a breakpoint at the “println” line by clicking to the left of the line number so that a small red circle appears.

  3. From the Run menu, select “Start Debugging” (or just hit the F5 key).

    The program will start executing, but will pause at the breakpoint.

  4. Click the debug symbol on the left to open the debugging console. In the left column you will see the list of visible variables. Expand args to view its values.

  5. A toolbar has also appeared across the top center of the window. Hover your mouse over the various buttons in the toolbar to find the options for resuming execution and for stepping through the code. Use these to move forward through the rest of the function.

3.2 Eclipse

  1. From the File menu, create a new Java project in a directory of your choice.

    (Clear the “Use default location” checkbox and use the “Browse…” button to select a directory outside of your Eclipse workspace directory.)

  2. From the File menu, select “New”, then “Class”. Name your class “Hello”, check the box to create “public static void main”, then click “Finish”.

  3. Your new Hello.java file should be open in the editor. In the body of the function, put the statement:

    System.out.println("CLI Argument was " + args[0]);
    

    Save the file.

  4. In the right column, right-click on Hello.java and select “Run As”, “Java Application”.

    The program will run, but will complain about an out of bounds error.

    That’s because the program tries to print the first command line parameter (in the array args) and we did not supply any.

  5. In the right column, right-click on Hello.java and select “Run As”, then “Run Configurations…”.

    You might see a configuration already set up and named “Hello”. If not, select “Java Application” and then click the “New launch configuration” icon.

  6. In the Arguments tab, under “Program arguments:”, type “Hello world”, then click the “Run” button. This time, the program should run correctly.

  7. Set a breakpoint at the “println” line by double-clicking just to the left of the line number. A small blue circle should appear to mark the breakpoint.

  8. In the right column, right-click on Hello.java and select “Debug As”, then “Debug Configurations…”.

    Select the “Hello” configuration and click the “debug” button.

    The program will start executing, but will pause at the breakpoint.

  9. In the right column you will see the list of visible variables. Expand args to view its values.

  10. Hover your mouse over the various buttons in the toolbar to find the options for resuming execution and for stepping through the code. Use these to move forward through the rest of the function.