0

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.

Abdul
  • 2,002
  • 7
  • 31
  • 65
Anjana
  • 873
  • 7
  • 22

2 Answers2

1

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

RaffoSorr
  • 405
  • 1
  • 5
  • 14
  • Thanks Raffolox . I use Linux. So extracting the jdk binary, copying the class file in it and running using `./bin/java MainClass` just worked ! – Anjana Jun 12 '17 at 11:44
1

You may do following:

  • Extract each 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.

cse
  • 4,066
  • 2
  • 20
  • 37