NonStop Server for Java 6.0 Programmer's Reference
c. Compile the Java source code by using the Java compiler, javac, which is part of the
installed NonStop Server for Java 6.0 product. Type the following command at the OSS
prompt:
$javac HelloWorld.java
If compilation is successful, the compiler produces a Java class file called
HelloWorld.class. Once you have the class file, your program is ready to run.
d. Check to see that the HelloWorld.class file has been created by typing:
$ls -l HelloWorld.class
If the file is not present or if you received an error message, check for typographical
errors in your source code. Fix them, and perform sub-steps c and d again until you have
a class file.
6. Run the Program by Using the java Tool.
a. At the OSS prompt, ensure that the position is in the directory where your
HelloWorld.class file is stored. For information about changing position, see step
5b.
b. To run the HelloWorld program (also called an application), type the following command
at the OSS prompt:
$java HelloWorld
Note that you should not type java HelloWorld.class. All Java classes have the
.class extension. Typing .class at the end causes an error message.
Your Java application displays the message, "Hello World!".
Specifying the CPU and Process Name with Which an Application Runs
You can specify which CPU an application process runs in and its process name by using options
of the run utility. The run utility starts OSS programs with specific attributes.
The format of the command to specify the CPU where a Java application is to run is:
run -cpu=cpu_number java class_name
For example, the command to run Java in CPU 3 is:
$run -cpu=3 java HelloWorld
The format of the command to give a java process a process name is:
run -name=/G/process_name java class_name
For example, the command to give Java the process name $APPJ is:
$run -name=/G/appj java HelloWorld
where the /G directory identifies the Guardian fileset. For information about the
/G directory, see the Open System Services User's Guide.
The following example combines more than one run option in a single command:
$run -name=/G/japp -cpu=3 java HelloWorld
For more information about the run(1) utility, see the Open System Services Shell and Utilities
Reference Manual.
34 Getting Started










