问题
So I have the latest version of JRE 7 on my computer, and everything is working fine. Lately, I've downloaded a program that requires JRE 6. I know where all of the files are located on my computer, all I'm asking is the .bat file code to run a specific version of Java with only that program. I am somewhat of a newbie when it comes to Windows and Java PATH structure, so
Stanford's computer science course has you use a modified version of Eclipse to code in Java, and it was created when Java was still in version 6. If you are familiar with this, then you may know of karel the robot, a Java application that opens in Eclipse. When I tried to run this, the Karel program did not appear; only a blank screen. I found a youtube video about using Karel and many of the people in the comments had been having this problem, and some said that using JRE 6 fixed it. Also on the installation instructions, it said to use JRE 1.6, but I thought it would work with JRE 7
回答1:
you can call each java.exe directly.
You can create 2 batch file named java6.bat and java7.bat :
java6.bat
@echo off
"C:\Program Files\Java\jre6\bin\java.exe" %*
java7.bat
@echo off
"C:\Program Files\Java\jre7\bin\java.exe" %*
to call a program with jre6
java6 -jar helloworld.jar
and to call a program with jre7
java7 -jar helloworld.jar
回答2:
If you mean this program then I had no problem launching it with java 7

However if you really need java 6 for operating it then you could write some .bat
file like this:
@echo off
set JAVA_HOME=C:\oracle\jdk1.6
set MY_CLASSPATH=lib\karelj.jar;lib\silk.jar
%JAVA_HOME%\bin\javaw.exe -cp %MY_CLASSPATH% karel.swingui.Main
来源:https://stackoverflow.com/questions/21050538/how-to-run-a-specific-version-of-java-with-a-program