Creating the simple Hello World Java™ program
is a great place to start when becoming familiar with the IBM Developer
Kit for Java.
To create, compile, and run your own Hello World Java program, perform the following steps:
- Map a network drive to your system.
- Create a directory on your server for your Java applications.
- On the command line, type:
CRTDIR DIR('/mydir')
where mydir is
the name of the directory you are creating.
Press the Enter key.
- Create the source file as an American Standard Code for
Information Interchange (ASCII) text file in the integrated file system.
You can either use an integrated development environment (IDE) product
or a text-based editor such as Windows Notepad
to code your Java application.
- Name your text file
HelloWorld.java
.
- Make sure that your file contains this source code:
class HelloWorld {
public static void main (String args[]) {
System.out.println("Hello World");
}
}
- Compile the source file.
- Enter the Start Qshell (STRQSH) command to start the
Qshell Interpreter.
- Use the change directory (cd) command to change the
current directory to the integrated file system directory that contains
the
HelloWorld.java
file.
- Enter
javac
followed by the name of
the file as you have it saved on your disk. For example, enter javac
HelloWorld.java
.
- Set the file authorities on the class file in the integrated
file system.
- Run the class file.
- Ensure that your Java classpath
is set up correctly.
- On the Qshell command line, type
java
followed
by HelloWorld
to run your HelloWorld.class
with
the Java virtual machine. For example, enter java
HelloWorld
. You can also use the Run Java (RUNJVA)
command on your system to run HelloWorld.class
:
RUNJVA CLASS(HelloWorld)
"Hello World"
prints to your screen
if everything was entered correctly. If running in the Qshell environment,
the shell prompt (by default, a $) appears, indicating that the Qshell
is ready for another command.
- Press F3 (Exit) or F12 (Disconnect) to return to the
command entry display.
You can also easily compile and run your Java application
using System
i Navigator, a
graphical user interface for performing tasks on your system.