Creating, compiling, and running a HelloWorld Java program

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:

  1. Map a network drive to your system.
  2. Create a directory on your server for your Java applications.
    1. On the command line, type:
           CRTDIR DIR('/mydir')

      where mydir is the name of the directory you are creating.

      Press the Enter key.

  3. 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.
    1. Name your text file HelloWorld.java.
    2. Make sure that your file contains this source code:
           class HelloWorld {
                public static void main (String args[]) {
                     System.out.println("Hello World");
                }
           }
  4. Compile the source file.
    1. Enter the Start Qshell (STRQSH) command to start the Qshell Interpreter.
    2. Use the change directory (cd) command to change the current directory to the integrated file system directory that contains the HelloWorld.java file.
    3. Enter javac followed by the name of the file as you have it saved on your disk. For example, enter javac HelloWorld.java.
  5. Set the file authorities on the class file in the integrated file system.
  6. Run the class file.
    1. Ensure that your Java classpath is set up correctly.
    2. 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)
    3. "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.
    4. Press F3 (Exit) or F12 (Disconnect) to return to the command entry display.