*
The moose likes Beginning Java and the fly likes Multiple JDK's and JRE's Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Multiple JDK Watch "Multiple JDK New topic
Author

Multiple JDK's and JRE's

Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

I have need to run at least two different JDK versions, 1.3.1 and 1.4.
What is the best way to compile code using the two individually without having to be in the JDK's Bin directory, or using an absolute path to that JDK's Bin Directory every time.
I was thinking of using a batch file, but I don't know how I would get the batch file to take in arguments. i.e java1.bat myProgram where java1.bat runs the JAVAC for 1.3.1 and myProgram is the program to be compiled.
Thanks


GenRocket - Experts at Building Test Data
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
I have several bat files out there.
For instance I have j131.bat, j140.bat etc. When I want to use a particular release, I run the bat that sets up a different path and classpath on the fly.
I just work in the working directory that I set up for each of these.
Then you can just work as normal.
However, If you want to invoke a particular JRE when starting your program (perhaps a different one from what your normal classpath points to) you can just specify when you invoke the application. The actual call to the app is bolded.
example RunAPP.bat:

cd \"Program Files"\app
path = .;C:\"Program Files"\app;C:\"Program Files"\app\jre\bin;
"c:\Program Files\app\jre\bin\javaw" -classpath .;"c:\Program Files\app";"c:\Program Files\app\app.jar";"c:\Program Files\app\deploy.jar";"c:\Program Files\app\jre\lib\rt.jar";"c:\Program Files\app\jre\lib\jaws.jar";"c:\Program Files\app\jre\lib\i18n.jar";"c:\Program Files\app\classes12.jar";"c:\Program Files\app\images" app.client.APPDesktop "c:\Program Files\app\APP.properties"


"JavaRanch, where the deer and the Certified play" - David O'Meara
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

So instead of running a batch file that runs the compiler, you just set up a batch file that resets your paths to whatever you need them set to. Smart Lady
Thanks Cindy. As always you have solved my problem.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Multiple JDK's and JRE's
 
Similar Threads
Java on CD-ROM
Axis2 java2wsdl
Exception in displaying data in a pdf format
setDefaultClose
How to compile a package