Hello World in Java (Linux)


This document instructs you on how to set up a Java programming environment for your Linux Linux logo computer. It also provides a step-by-step guide for creating and compiling a Java program in IntelliJ and executing it from the command line.

You will need a 64-bit version of Linux.


Warning:

Beta version of instructions. Please send bug reports to wayne@princeton.edu.

Todo: replace Mac OS X screenshots with Linux screenshots.


    1.   Install Java


You will use Java SE Development Kit 10 (JDK 10).

Note

If you already have JDK 10 installed, you can skip this step.


    2.   Install Command-Line Tools


Next, you will install our textbook libraries, Spotbugs, PMD, and Checkstyle to /usr/local/lift and associated wrapper scripts to /usr/local/bin.

    3.   Install IntelliJ


Now, you will install IntelliJ.


    4.   Open a Project in IntelliJ


You will develop your Java programs in an application called IntelliJ IDEA, Community Edition.

IntelliJ organizes Java programs into projects. In our context, each project corresponds to one programming assignment. A typical project contains Java programs, associated data files, and course-specific settings (such as compiler options and style rules).


    5.   Create a Program in IntelliJ


Now you are ready to write your first Java program. IntelliJ features many specialized programming tools including line numbering, syntax highlighting, bracket matching, auto indenting, auto formatting, auto importing, variable renaming, and continuous code inspection.


    6.   Compile and Execute the Program (from IntelliJ)


Now, it is time to execute (or run) your program. This is the exciting part, where your computer follows the instructions specified by your program. Before doing so, you must compile your program into a form more amenable for execution on a computer.


Tip

Use the Tools menu to compile and execute your program from IntelliJ. The Build and Run menus support additional options (such as a debugger) for advanced programmers.

Also be sure that the main editor window is active before using the Tools menu (e.g., by clicking the code you want to compile or execute).


    7.   Compile and Execute the Program (from the command line)


The command line is a simple and powerful mechanism for controlling your programs. It supports features that are unavailable in IntelliJ, including file redirection and piping.


    8.   Textbook Libraries (from the command line)


To make our textbook libraries accessible to Java from the command line, you will use our wrapper scripts.