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.

1
  • More like extract then pathToJdk/bin/java pathToYourClassFile Commented Jun 12, 2017 at 11:21

2 Answers 2

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

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks Raffolox . I use Linux. So extracting the jdk binary, copying the class file in it and running using ./bin/java MainClass just worked !
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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.