# java-The Java Interpreter

java interprets (executes) Java bytecodes.

## SYNOPSIS

    java [ options ] classname <args>

    java_g [ options ] classname <args>

## DESCRIPTION

java is the Java interpreter, which executes Java programs.

The classname argument is the name of a class. classname must be fully qualifed by including its package in the name, for example:

        java java.lang.String

Note that any arguments that are after classname in the call to java are passed to the class.

The bytecodes for the class are in a file called classname.class generated by compiling the corresponding class source file with javac. All Java bytecode files have .class as their extension, which the compiler automatically adds when the class is compiled. classname must contain a `main()` method, which java executes and then exits, unless `main()` creates one or more threads. If any threads are created by `main()` then java doesn't exit until the last thread exits. The `main()` method is defined as follows:

        class Aclass {
            public static void main(String argv[]){
                < main code >
            }
        }

When you define your own classes you need to specify their location. Use CLASSPATH to do this. CLASSPATH consists of a semicolon separated list of directories that specifies the path. For example:

        .;C:\users\lindholm\classes

Note that the system always appends the location of the system classes onto the end of the class path unless you use the -classpath option to specify a path.

Ordinarily, source files are compiled using javac then the program is run using java. However, java can be used to compile and run programs when the -cs option is used. As each class is loaded its modification date is compared to the modification date of the class source file. If the source has been modified more recently, it is recompiled and the new bytecode file is loaded. java repeats this procedure until all the classes are correctly compiled and loaded.

The interpreter can determine whether a class is legitimate through the mechanism of verification. Verification ensures that the byte codes being interpreted do not violate any language constraints.

java_g is a non-optimized version of java suitable for use with debuggers like dbx or gdb.

## OPTIONS

-cs, -checksource
  When a compiled class is loaded, causes the modification time of the class bytecode file to be compared to that of the class source file. If the source has been modified more recently, it is recompiled and the new bytecode file is loaded.

-classpath path
  Specifies the path java uses to look up classes. Overrides the default or the CLASSPATH environment variable if it is set. Directories are separated by semicolons. Thus the general format for path is:

          .;<your_path>

  For example:

          .;C:\users\lindholm\classes;D:\java\classes

-ms x
  Sets the size of the memory allocation pool (the garbage collected heap) to x. The default units for x are bytes. x must be > 1000 bytes. You can modify the meaning of x by appending either the letter "k" for kilobytes or the letter "m" for megabytes. The default is "-ms3m", for 3 megabytes of memory.

-noasyncgc
  Turns off asynchronous garbage collection. When passed as an option no garbage collection takes place unless it is explicitly called or the program runs out of memory. Normally garbage collection runs as an asynchronous thread in parallel with other threads.

-prof
  Causes java to produce profiling data. When used, java creates a file called "java.prof" in the current directory, when it exits. This file can be passed to javaprof for prettyprinting.
-ss x
  Each Java thread has two stacks: one for Java code and one for C code. The -ss option sets the maximum stack size that can be used by C code in a thread to x. Every thread that is spawned during the execution of the program passed to java has x as its C stack size. The default units for x are bytes. x must be > 1000 bytes. You can modify the meaning of x by appending either the letter "k" for kilobytes or the letter "m" for megabytes. The default stack size is 64 kilobytes ("-ss 64k").

-oss x
  Each Java thread has two stacks: one for Java code and one for C code. The -oss option sets the maximum stack size that can be used by Java code in a thread to x. Every thread that is spawned during the execution of the program passed to java has x as its Java stack size. The default units for x are bytes. x must be > 1000 bytes. You can modify the meaning of x by appending either the letter "k" for kilobytes or the letter "m" for megabytes. The default stack size is 400 kilobytes ("-ss400k").

  This option is not supported in HotJava alpha 2 release for NT.

-t
  Prints a trace of the instructions executed ( java_g only).

-v, -verbose
  Causes java to print a message to stdout each time a class file is loaded.

-verify
  Runs the verifier on all code.

-verifyremote
  Runs the verifier on all code that is loaded into the system via a classloader. verifyremote is the default for the interpreter.

-noverify
  Turns verification off.

-verbosegc
  Causes the garbage collector to print out messages whenever it frees memory.

## ENVIRONMENT VARIABLES

CLASSPATH
  Used to provide the system a path to user-defined classes. Directories are separated by semicolons, for example,

          .;C:\users\lindholm\classes;D:\java\classes

## SEE ALSO

javac, javah, javaprof, javap, javadoc The Java Language Specification