Apr 7, 2012

java


java/java_g

You can use the Java interpreter to verify and execute your code. To run the Java interpreter, enter the executable name, options, class name (without the file name extension, unlike javac), and arguments as outlined here:

    java [ options ] classname args
    java_g [ options ] classname args

For our example, run the following command:

    java HelloWorld

This should produce the following output:

    Hello World!

Ordinarily, you compile source code with javac and then execute it using Java. However, Java can be used to compile and run bytecode 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.

java_g is a non-optimized version of Java that is suitable for use with debuggers such as jdb.

There are several options that you can feed the interpreter that change its behavior. Below Table lists all of the command-line options for the Java interpreter.


Command
Function
-cs, -checksource
Recompiles any class whose .java source file is later than its .class file.
-classpath path
Overrides the CLASSPATH environment variable.
-mx x
Sets maximum size of memory allocation pool to x. Pool must be larger than 1,000 bytes and a k or m must be appended to the number to indicate size. The default is 16MB.
-ms x
Sets the size of the memory allocation pool to x. Pool must be larger than 1,000 bytes and a k or m must be appended to the number to indicate size. The default is 1MB.
-noasyncgc
Turns off asynchronous garbage collection. The only time garbage collection occurs is when the program calls for it or runs out of memory.
-ss x
Sets the maximum stack size for C threads to x. Must be greater than 1,000 bytes and a k or m must be appended to the number to indicate size.
-oss x
Sets the maximum stack size for Java threads to x.
-v, -verbose
Prints a message to stdout when a class is loaded.
-verify
Uses verifier on all code.
-verifyremote
Uses verifier only on classes loaded with classloader.
-noverify
Disables verifier.
-verbosegc
Prints a message when garbage collector frees memory.
-t
Prints trace of an instruction being executed. Only available with javag.
-debug
Allows jdb connection to current session of Java interpreter. Displays password when debugging session is started.
-DpropName=newVal
Enables user to change values at runtime. Requires the full packaging extension to the class variable.





0 comments :

Post a Comment