Hello, World in Java on Linux


This document instructs you on how to setup a Java programming environment under the Debian flavor of Linux, and provides a step-by-step guide to creating, compiling, and executing a Java program. Red Hat, SuSE, Mandrake, Debian, Gentoo, and other Linux distros should be similar. All of the software is freely available on the web.

Java /td>

You will use the Java compiler javac to compile your Java programs and the Java interpreter java to run them.

Command Line Interface

You will type commands in an application known as the shell. Since you're using Linux, we assume you're somewhat familiar with it (as you used it in the previous step!).

If you plan to take COS 217, you might want to buy the required book Programming with GNU Software by Loukides and Oram. It contains an overview of UNIX from the user's point of view. It also describes shell fundamentals, with reference to the bash, Bourne, and C shells.


Text Editor

You will type and edit your programs in a text editor called JEdit. JEdit is similar to conventional word processors like MS Word and Notepad, but it features many specialized programming tools including syntax highlighting, bracket matching, auto indenting, indent shifting, line numbering, and commenting out code. It's even written in Java.

Create the Program

Now you are ready to write your first Java program.

Compile the Program

It is now time to convert your Java program into a form more amenable for executing on a computer.

Execute the Program

Now it is time to run your program. This is the fun part.

Congratulations, you are now a Java programmer!

Troubleshooting

How do I configure vi to replace tabs with four spaces? Edit your .exrc file and add the commands ":set ts=4" to display the tabs as four spaces and ":set expandtab" to translate the tabs into spaces.