# Java section
setenv JAVA_HOME=/usr/local/jdk1.4
setenv CLASSPATH .
setenv PATH ${PATH}:${JAVA_HOME}/bin
# end of Java section
Save the file, log out and log in again (or just type source
.tcshrc from the shell prompt). CLASSPATH is the variable
used by the java compiler and interpreter to know where to look for compiled
classes. By setting this variable to ".", you are asking the interpreter
and compiler to look into your current directory first.
java -version
The java interpreter will answer with the JDK version you will
be using to compile and run Java programs.
public class HelloWorld {To compile this program, from the shell prompt, type:
public static void main(String args[]) {
System.out.println("Hello World!");
}
}
javac HelloWorld.java
You should now have a HelloWorld.java and a HelloWorld.class
in your current directory. The first is, of course, the program
you typed in. The second is the output of the javac compiler.
However, contrary to the output of a C or C++ compiler, you may not directly
execute this .class file. This file will be interpreted
by the Java interpreter.
java HelloWorld
If all is well, the program should run and you should see the "Hello
World!" string as output.
First, update your LD_LIBRARY_PATH environment variable as follows (you may add this to the Java section of your .cshrc):
setenv LD_LIBRARY_PATH ${LD_LIBRARY_PATH}:/usr/local/java/lib
The define the following environment variable:
setenv JAVA_COMPILER sunwjit_opt
(WARNING: once you set up this veriable, the JIT compiler will be invoked every time you run the java interpreter. If you only want to test the JIT compiler, do not set the JAVA_COMPILER variable in your .cshrc file.)
That's it! Now, every time you run a Java program with the java
interpreter, the JIT compiler will dynamically compile the necessary .class
files into Sun-Solaris' machine code and run that compiled code.
You do not need to use any special flag to invoque the JIT compiler.
See http://www.sun.com/solaris/jit
for more details on how the JIT compile works.
Home | Information | Academics | People | Resources | Contact
The Department of Computer Science at the University of Illinois at Springfield
Copyright© 2002 University of Illinois at Springfield