如何在Windows上更改Java运行时版本(7)? [英] How can I change the Java Runtime Version on Windows (7)?

查看:134
本文介绍了如何在Windows上更改Java运行时版本(7)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在Windows上更改Java运行时版本。

How can I change the Java Runtime Version on Windows.

我为某些测试安装了Java  7现在我需要旧的java6作为系统默认值,但是我不想卸载Java 7(我需要它以便以后的测试)。我可以在控制面板/ Java / JRE选项卡中更改系统使用的 JRE 吗?我可以更改/编辑/添加/删除用户使用的版本,但不能使用系统。

I installed Java 7 for some tests, and now I need the old java6 as system default, but I don't want to uninstall the Java 7 (I need it for later tests). Can I change the system-used JRE in the control panel/Java/JRE tab? I can change/edit/add/delete the user-used version, but not the system-used.

推荐答案

For Java 应用程序,即(通常)以 .jar 文件的形式交付的程序,以 java -jar xxx.jar开头或通过执行相同操作的快捷方式,将启动的JRE将是 PATH 中找到的第一个。

For Java applications, i.e. programs that are delivered (usually) as .jar files and started with java -jar xxx.jar or via a shortcut that does the same, the JRE that will be launched will be the first one found on the PATH.

如果你安装了JRE或JDK,那么找到 .exe 的可能位置就在 C:\Program Files\JavaSoft\JRE\xyz 。但是,我发现一些开箱即用的Windows安装(也?)有 java.exe javaw.exe <的副本/ code>在 C:\ winnt \ system32 (NT和2000)或 C:\ windows \ system (Windows 95,98)。这通常是Java的老版本:1.3,也许?你想在命令窗口中做 java -version 来检查你是不是在运行一些过时的Java版本。

If you installed a JRE or JDK, the likely places to find the .exes are below directories like C:\Program Files\JavaSoft\JRE\x.y.z. However, I've found some "out of the box" Windows installations to (also?) have copies of java.exe and javaw.exe in C:\winnt\system32 (NT and 2000) or C:\windows\system (Windows 95, 98). This is usually a pretty elderly version of Java: 1.3, maybe? You'll want to do java -version in a command window to check that you're not running some antiquated version of Java.

您当然可以通过在命令行或快捷方式定义中明确声明java.exe / javaw.exe的路径来覆盖PATH设置,甚至不使用它。

You can of course override the PATH setting or even do without it by explicitly stating the path to java.exe / javaw.exe in your command line or shortcut definition.

如果您从浏览器运行小程序,或者也可能 Java Web Start应用程序(它们看起来像应用程序只要有自己的窗口,但是从浏览器启动它们,JRE的选择由一组注册表设置决定:

If you're running applets from the browser, or possibly also Java Web Start applications (they look like applications insofar as they have their own window, but you start them from the browser), the choice of JRE is determined by a set of registry settings:

Key: HKEY_LOCAL_MACHINE\Software\JavaSoft\Java Runtime Environment
Name: CurrentVersion
Value: (e.g.) 1.3

使用此方案创建更多注册表项:

More registry keys are created using this scheme:

(e.g.) 
HKEY_LOCAL_MACHINE\Software\JavaSoft\Java Runtime Environment\1.3   
HKEY_LOCAL_MACHINE\Software\JavaSoft\Java Runtime Environment\1.3.1

即一个用于专业,一个用于次要版本号。这些键中的每一个都具有如下值(显示的示例):

i.e. one for the major and one including the minor version number. Each of these keys has values like these (examples shown):

JavaHome    : C:\program Files\JavaSoft\JRE\1.3.1
RuntimeLib  : C:\Program Files\JavaSoft\JRE\1.3.1\bin\hotspot\jvm.dll
MicroVersion: 1

...您的浏览器会查看这些设置以确定要启动哪个JRE。

... and your browser will look to these settings to determine which JRE to fire up.

由于Java版本经常变化,现在有一个名为Java控制面板的向导,用于手动切换浏览器的Java版本。这适用于IE,Firefox以及其他可能的Opera和Chrome:它是Windows系统设置应用程序中的'Java'小程序。您可以选择任何一个已安装的JRE。我相信该向导会对这些注册表项进行调整。

Since Java versions are changing pretty frequently, there's now a "wizard" called the "Java Control Panel" for manually switching your browser's Java version. This works for IE, Firefox and probably others like Opera and Chrome as well: It's the 'Java' applet in Windows' System Settings app. You get to pick any one of the installed JREs. I believe that wizard fiddles with those registry entries.

如果您像我一样并通过简单地擦除目录来卸载旧Java版本,您会发现这些选择中也有幽灵;所以请确保您选择的JRE对应于完整的Java安装!

If you're like me and have "uninstalled" old Java versions by simply wiping out directories, you'll find these "ghosts" among the choices too; so make sure the JRE you choose corresponds to an intact Java installation!

其他一些答案建议设置环境变量 JAVA_HOME 。这是同时过时的建议。 Sun开始意识到,围绕Java 2,这个环境设置是

Some other answers are recommending setting the environment variable JAVA_HOME. This is meanwhile outdated advice. Sun came to realize, around Java 2, that this environment setting is


  1. 不可靠,因为用户经常设置错误,

  2. 是不必要的,因为运行时很容易找到Java库目录,知道它们位于相对于启动java.exe或javaw.exe的路径的固定路径中。

几乎没有任何现代Java软件需要或尊重 JAVA_HOME 环境变量。

There's hardly any modern Java software left that needs or respects the JAVA_HOME environment variable.

更多信息:

  • http://java.sun.com/j2se/1.3/runtime_win32.html
  • http://www.rgagnon.com/javadetails/java-0604.html

...以及有关多版本支持的一些有用信息:

...and some useful information on multi-version support:

  • http://www.rgagnon.com/javadetails/java-0604.html

这篇关于如何在Windows上更改Java运行时版本(7)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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