NonStop Server for Java 7.0 Programmer's Reference

3 Getting started
Although this manual assumes that you are familiar with using Java and HP NonStop Open System
Services (OSS), this section provides background information for those who are not familiar with
these products. Additionally, this section explains how to perform common tasks that are
characteristic to running Java applications on NonStop systems. The topics are:
“Tutorial: Running a simple program, HelloWorld” (page 30)
“Specifying the CPU and process name” (page 31)
“Configuring a Java Pathway serverclass” (page 32)
Tutorial: Running a simple program, HelloWorld
After NSJ7 is installed, use the following steps to create and run the HelloWorld program.
1. Create a Java source file.
Perform either steps a, b, and c or step d only.
a. Using an editor, create a file that contains the following source code.
b. Name the file HelloWorld.java.
c. Place the file in the OSS file space by using FTP.
/**
* The HelloWorld application implements a java class that
* displays "Hello World!" to the standard output.
*/
class HelloWorld
{
public static void main(String[] args)
{
System.out.println("Hello World!");
}
}
d. Alternatively, at the OSS prompt, use the cat command to create the HelloWorld.java
file and type the contents of the HelloWorld program listed previously.
$cat> HelloWorld.java
type-contents-of-the-file
(Ctrl+y)
2. Set the PATH environment variable.
Add the directory where the NSJ7 executable file is installed to your PATH environment
variable.
For the standard installation, type the following command at the OSS prompt:
$export PATH=/usr/tandem/nssjava/jdk170_h70/bin/:$PATH
If the NSJ7 is installed in a nonstandard location, /home/lee, type:
$export PATH=/home/lee/nssjava/jdk170_h70/bin/:$PATH
3. Check your path settings.
Optionally, you can check whether your path is set correctly by using the whence command.
Type:
$whence -v java
30 Getting started