Here's a step-by-step guide to using the JDK 1.1 beta with Visual J++
Current versions of Microsoftโs Visual J++ Java development system do not support Java 1.1. So how do you integrate Sunโs upcoming Java Development Kit (JDK) version 1.1 with Visual J++? Donโt panic! This tip will show you the way.
Before you begin, a disclaimer and some warnings
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.
Step 1: Set it up
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.โ
Step 2: Compile it
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.
And there you have it. Remember, this technique uses undocumented features; there are no guarantees that it will work with anything but the current Microsoft Visual J++.


