Reputation: 883
I have downloaded jdk binaries (jdk.tar.gz
) of different JDK versions, say 8u92, 8u121
and 8u131
in a directory.
I want to run a Java program in each of these java versions and know the output. Is there a way to do this?
Something like extract jdk.tar.gz
, put the class file somewhere in the jdk and execute?
Thanks ahead.
Upvotes: 0
Views: 1340
Reputation: 4104
You may do following:
jdk.tar.gz
in different folder(say 8u92
, 8u121
and 8u131
).Write a small script to run class files with different JRE version
. Following is a script for windows platform:
@echo OFF
setlocal
set JDK_8U92=<PATH_OF_JDK_U92_FOLDER_WHERE_IT_IS_EXTRACTED>
set JDK_8U121=<PATH_OF_JDK_U121_FOLDER_WHERE_IT_IS_EXTRACTED>
set JDK_8U131=<PATH_OF_JDK_U131_FOLDER_WHERE_IT_IS_EXTRACTED>
%JDK_8U92%/bin/java.exe %1 >%1_JDK_8U92.txt
%JDK_8U121%/bin/java.exe %1 >%1_JDK_8U121.txt
%JDK_8U131%/bin/java.exe %1 >%1_JDK_8U131.txt
endlocal
@echo ON
Save the script file. Here I assume file name is MultiJDKExecute.bat
.To run a class file name Abc.class
, run command MultiJDKExecute.bat Abc
Now you can see the respective out put in <ClassName>_JDK_8U_<JDK Version>.txt
Note: If you wish to see output on screen then remove the option >%1_JDK_8U<JDK Version>.txt
from each lines.
Upvotes: 1
Reputation: 404
The most easy way is to extract the three JDK versions, put the .class files in each folder, run the terminal/cmd from each folder and use java.exe MainClass
This way you are not using the java executable in your classpath but the java executable in the folder you are currently in
Upvotes: 1