Hello World in Java (Mac OS X)


This document instructs you on how to set up a Java programming environment for your Mac OS X Apple 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 Mac running Mac OS X 10.15 (Catalina) to Mac OS X 13.5 (Ventura).


    0.   Install the Java Programming Environment


The installer installs and configures a Java programming environment, including OpenJDK 11 and IntelliJ IDEA, Community Edition 2023.2.


    1.   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, style rules, and textbook libraries).


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


    3.   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 LIFT menu to compile and execute your program from IntelliJ. The Build and Run menus support additional options for advanced programmers.

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


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


The command line is a simple and powerful mechanism for controlling your programs (e.g., command-line arguments, file redirection, and piping). IntelliJ supplies an embedded terminal for easy access to the command line.


    5.   Textbook Libraries (from the command line)


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