This program modifies the Visual J++ (VJ++) system so that the Sun JDK 1.1 compiler and run time are invoked instead of the Microsoft versions. This is an exclusive change: You cannot (easily) switch between this and the "normal" VJ++ environment. You have to reverse the regedit changes.
The Developer Studio has a number of compile and run-time switches that are not understood by the JDK. These are ignored by the program. Note that the debugging switches are not implemented either -- mainly because you (probably) cannot use the Developer Studio debugger with JDK 1.1 compiled code.
We have not checked that the environment variables are set, and there are other occurrences of "bad coding practice." (These are Tim's, not Rob's, by the way!) Feel free to tidy up the code.
Note: This example is entirely unsupported, and you use it totally at your own risk.
This program is used as a hook to replace calls to the Microsoft jvc compiler or the jview virtual machine interpreter with calls to the Sun equivalents -- javac and java, respectively.
Set the environment variables `JAVACLASS' and `JAVABIN' to point to your environment. JAVACLASS is a standard classpath, and will have `.' prepended to it. JAVABIN is the directory your Java binary files are in. You can change these environment variable names in the source if you wish.
Compile and link to a stand-alone .exe file, and place it in a location of your choosing.
Modify the registry (using regedit), search for jvc, and replace the entry with the name (and path) of the generated .exe file to point to your executable. Modify the settings
for your project by setting the "RuntimeInterpreter" option to be your executable. Enter `-run' as the first parameter for
the interpreter.
Now, when you build your project, the Developer Studio will call javac (via the executable) with the given parameters, and all output will go to the normal output window in VJ++. Double-clicking
on errors/warnings should take you to the line where the error/warning occurred.
When you execute your project, the Developer Studio will call java for the given class -- and the DOS window will wait until you press "Return."
The program reads the command line given to javac, and converts each parameter (if necessary) to an equivalent parameter accepted by jvc. Some parameters are ignored entirely (for example, classpath specs). Others have a straight conversion (for example, /g
=> -g for debugging).
We then invoke the new command line -- that is, call javac with the translated options -- and read the standard error from the compiler. (Any compiler errors or warnings get sent to
the standard error.) We translate the standard error into the error message format given by the Microsoft javac and hand these back to the development environment, which has no idea that it was javac, not jvc, that produced the message.
blue j environmentBy Anonymous on December 22, 2008, 10:54 amhow to access
Reply | Read entire comment
View all comments