University of Southern California

ITS Information Technology Services

About Java

JAVA at USC

The environment necessary to program and run JAVA applications is provided on all ITS UNIX hosts. While ITS supports the use of the JAVA tools, ITS does not support programming syntax or program debugging in any way.

Setting up your Environment

There are multiple JAVA environments available on the USC Solaris systems. It is recommended that you use the JAVA Development Kit found in /usr/usc/jdk/. There are several different versions in that directory. It is suggested that you either the version required by your program or class, the default version, or the new version. ITS recommends that you use the default version.

To set up your environment to use the JAVA tools in the default version of JDK, type the following command:
source /usr/usc/jdk/default/setup.csh
To avoid typing in this command for every UNIX session, add that command to a new line at the end of your ~/.login file.

Using JAVA

To make a JAVA program, you must first create a program source file. To create this file you will need to use a text editor. A sample file is provided at the end of this document to get you started. Once you have your .java source file, you must convert it to an executable JAVA .class program with the javac command. If your source file were called myProgram.java, your command would be javac myProgram.java. Once your .class file is built, you can run it with the java command. Even though javac creates a file like myProgram.class, leave off the .class extension. So to run the .class file created from myProgram.java, type java myProgram.

Sample Program

Here is a sample program to get you started with JAVA. You can copy it into a file called myProgram.java, or you can download it here

import java.io.*;


public class myProgram
{
public static void main(String ARGS[]){
String printout=new
String("This is a Java Program.\n\n");
System.out.println(printout);

return;
}
}

Other Tools

There is an appletviewer application installed in the JDK directory which can be used to view JAVA applets embeded into html pages. If you embeded your applet in a file called appletHolder.html, the syntax would just be appletviewer appletHolder.html.

Getting Help

There are manpages for java and javac that explain their syntax. There are JAVA resources on the Internet, including http://java.sun.com. If you are programming for a class, please ask your TA or professor for help with JAVA programming syntax.

While the ITS Customer Support Center can help with the basic use of the JAVA tools, ITS does not support programming syntax or program debugging in any way. ITS will accept reports that these tools are not functioning properly. The ITS Customer Support Center can be reached at 213-740-5555 or consult@usc.edu.

Last updated:
February 04, 2011

Programming Documentation

The use of all USC computing resources is governed by the USC Computing Policies.