Monday, August 31, 2009

Using Microsoft Java From the Command Line
Microsoft's language tools (e.g., Visual C++ anv Visual J++) are organized around the Microsoft Developer Studio visual "shell" interface. Many users will never have to venture beyond this interface. But if you want to develop source code that can be built on both Windows and UNIX platforms you will probably have to use make/nmake which will reference the compiler from the "command line". Also, if you use software that originally ran on UNIX you may have to use the command line interface. In the case of Visual C++ once you discover that the C++ compiler is named cl things are pretty straight forward. For Microsoft Java I found command line use more obscure. This note discusses how to use Microsoft's Java from the command line.
The Microsoft Java Compiler: jvc.exe
The Microsoft Java compiler converts Java source into Java byte code. The convention is that Java source files end with the .java suffix. The Microsoft Java compiler reads a .java file and generates a .class file. The .class file can only be executed by the Java interpreter.
The Microsoft Java Interpreter (a.k.a. Java Virtual Machine): jview.exe
The jview program reads in a .class file for a console application and executes it. Currently I'm not sure what it does if it's given a GUI applet or application. From Microsoft's documentation it appears that these should be run on Wjview.exe.
The CLASSPATH environment variable
The CLASSPATH environment variable tells the Microsoft Java interpreter where to find libraries of classes. This variable can be set in the system dialog, which is under the control pannel.
A CLASSPATH example
Like VHDL (and I believe Ada), Java stores class libraries in a directory. I have been using a tool named ANTLR, which is a parser generator written in Java. The ANTLR tool, documentation etc... is installed in E:\antlr
The Java class library for ANTLR is in a subdirectory named antlr (e.g., E:\antlr\antlr). So I set CLASSPATH to E:\antlr. The ANTLR parser generator classis Tool. So to run the parser generator I use the following command line command:
jview antlr.Tool grammar.g
The CLASSPATH variable tells the jview Java interpreter to look in the directory E:\antlr. The argument antlr.Tool tells jview to look in the antlr subdirectory for the Tool.class file (which is Java byte code).

No comments:

Post a Comment