VMS Help JAVA, Description *Conan The Librarian (sorry for the slow response - running on an old VAX) |
Java expects the binary representation of the class to be in a file called file-name.CLASS, which is generated by compiling the corresponding source file with the JAVAC compiler. All Java class files end with the file name extension .CLASS, which the compiler automatically adds when the class is compiled. The class to be executed must contain a main method defined as follows: class Aclass { public static void main(String argv[]){ . . . } } The Java interpreter executes the main method and then exits, unless main creates one or more threads. If any threads are created by main, then the JAVA command does not exit until the last thread exits. When you define your own classes, you need to specify their location. Use the logicals CLASSPATH (for a UNIX style directory path) or JAVA$CLASSPATH (for an OpenVMS style directory path) to do this. The CLASSPATH logical consists of a colon-separated list of directories that specifies the path. For example: .:/home/xyz/classes:/usr/local/java/classes Also, unlike on UNIX systems, you must also explicitly specify the system classes on CLASSPATH. For example: $ define/nolog CLASSPATH "/sys$common/java/lib/JDK116_CLASSES.ZIP:." The JAVA$CLASSPATH logical lets you define a classpath using OpenVMS filespecs. The following two sample statements accomplish the same result: $ DEF JAVA$CLASSPATH USER1$:[SMITH.KIT]JDK115_CLASSES.ZIP,[] $ DEF CLASSPATH "/user1$/smith/kit/jdk115_class.zip:." Note that: o JAVA$CLASSPATH is a comma-separated list not enclosed in quotation marks. o JAVA$CLASSPATH overrides CLASSPATH if CLASSPATH is defined. NOTE All Java files that are to be read by any of the Java tools or that serve as input class libraries (listed in CLASSPATH) must be in Stream_LF format. To determine the record format of your file, do the following: $ DIR/FULL MyFile.java And observe the line: Record format By default, a file initially created on an OpenVMS system, with a text editor for example, will have variable-length record format. Although, for example, a *.JAVA file with variable-length record format compiles correctly if it is error-free, the compiler does not produce proper diagnostic outputs if a compilation error occurs. To get a file into Stream_LF record format, do the following: $ CONVERT/FDL=SYS$INPUT input_file-name output_file-name FILE ALLOCATION 4 BEST_TRY_CONTIGUOUS yes EXTENSION 0 ORGANIZATION sequential RECORD BLOCK_SPAN yes CARRIAGE_CONTROL carriage_return FORMAT stream_LF SIZE 0 If you use a non-Stream_LF formatted file in a CLASSPATH, errors like this result: Unable to initialize threads: cannot find class java/lang/Thread Ordinarily, you compile source files with JAVAC, then run the program using JAVA; however, JAVA can be used to compile and run programs when the /CHECKSOURCE qualifier is used. As each class file is loaded, its modification date is compared to the modification date of the class source file. If the source was modified more recently, it is recompiled and the new class 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 prior to their execution, class files do not violate any language constraints. You can specify the qualifiers for this command as one of the following: o OpenVMS DCL style qualifiers o Tru64 UNIX style switches To use the DCL style: $ DEFINE JAVA$USE_DCL 1 $ @SYS$MANAGER:JAVA$SETUP To use the Tru64 UNIX style: $ DEASSIGN JAVA$USE_DCL $ @SYS$MANAGER:JAVA$SETUP Both styles are documented.
|