如何通过程序运行特定版本的Java? [英] How to run a specific version of Java with a program?

查看:596
本文介绍了如何通过程序运行特定版本的Java?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我的计算机上装有最新版本的JRE 7,并且一切正常.最近,我下载了一个需要JRE 6的程序.我知道所有文件在计算机上的位置,我要问的是.bat文件代码,以便仅使用该程序运行特定版本的Java.在Windows和Java PATH结构方面,我还是个新手,所以

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

斯坦福大学的计算机科学课程要求您使用Eclipse的修改版本来进行Java编码,并且它是在Java仍为版本6时创建的.如果您熟悉这一点,那么您可能知道机器人karel就是Java在Eclipse中打开的应用程序.当我尝试运行此程序时,没有出现Karel程序.只有黑屏.我发现了一个有关使用Karel的youtube视频,评论中的很多人都遇到了这个问题,有人说使用JRE 6可以解决此问题.同样在安装说明中,它说可以使用JRE 1.6,但是我认为它可以在JRE 7中使用.

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

推荐答案

您可以直接调用每个java.exe.

you can call each java.exe directly.

您可以创建两个名为java6.bat和java7.bat的批处理文件:

You can create 2 batch file named java6.bat and java7.bat :

java6.bat

java6.bat

@echo off
"C:\Program Files\Java\jre6\bin\java.exe" %*

java7.bat

java7.bat

@echo off
"C:\Program Files\Java\jre7\bin\java.exe" %*

使用jre6调用程序

java6 -jar helloworld.jar

并使用jre7调用程序

and to call a program with jre7

java7 -jar helloworld.jar

这篇关于如何通过程序运行特定版本的Java?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆