如何设置默认的Java安装/运行时(Windows)? [英] How do I set the default Java installation/runtime (Windows)?

查看:174
本文介绍了如何设置默认的Java安装/运行时(Windows)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正处于安装JDK的情况,但我无法在浏览器中运行applet(我可能没有安装JRE)。

I'm in the situation where I've installed the JDK, but I can't run applets in browsers (I may not have installed the JRE).

但是,当我安装JRE时,它会破坏我的JDK作为默认运行时。这几乎打破了所有东西(Eclipse,Ant) - 因为它们需要服务器JVM。

However, when I install the JRE, it clobbers my JDK as the default runtime. This breaks pretty much everything (Eclipse, Ant) - as they require a server JVM.

没有 JAVA_HOME 环境这些天变量 - 它似乎只是使用一些注册表魔术(设置系统路径也没用)。以前,在我用它来恢复JDK后,我刚刚卸载了JRE。这次我想正确修复它。

There's no JAVA_HOME environment variable these days - it just seems to use some registry magic (setting the system path is of no use either). Previously, I've just uninstalled the JRE after I've used it to restore the JDK. This time I want to fix it properly.

这也体现了jre autoupdater - 曾几何时,我有一个JDK和JRE的工作设置,但是它更新并破坏了一切。

This also manifests itself with the jre autoupdater - once upon a time, I had a working setup with the JDK and JRE, but it updated and bust everything.

推荐答案

这在Windows上有点痛苦。这就是我的工作。

This is a bit of a pain on Windows. Here's what I do.

安装最新的Sun JDK,例如: 6u11 ,在 c:\ install \ jdk \sun \ 6u11 之类的路径中,然后让安装程序在默认情况下安装公共JRE放置( c:\program files\blah )。这将为大多数事情设置默认JRE。

Install latest Sun JDK, e.g. 6u11, in path like c:\install\jdk\sun\6u11, then let the installer install public JRE in the default place (c:\program files\blah). This will setup your default JRE for the majority of things.

根据需要安装较旧的JDK,如 c中的 5u18 :\ install\jdk\sun\5u18 ,但不要安装公共JRE。

Install older JDKs as necessary, like 5u18 in c:\install\jdk\sun\5u18, but don't install the public JREs.

在开发中,我有一个小批处理文件,我用它来为每个JDK版本设置命令提示符。基本上只需设置 JAVA_HOME = c:\ jdk \ sun \ _DDK_DESIRED 然后设置 PATH =%JAVA_HOME%\ bin;%PATH% 。这将把所需的J​​DK放在路径中,Ant和Maven等任何辅助工具都可以使用 JAVA_HOME 变量。

When in development, I have a little batch file that I use to setup a command prompt for each JDK version. Essentially just set JAVA_HOME=c:\jdk\sun\JDK_DESIRED and then set PATH=%JAVA_HOME%\bin;%PATH%. This will put the desired JDK first in the path and any secondary tools like Ant or Maven can use the JAVA_HOME variable.

路径很重要,因为大多数公共JRE安装都将链接的可执行文件放在 c:\ WINDOWS \ System32 \ _java.exe 中,通常覆盖大多数其他设置。

The path is important because most public JRE installs put a linked executable at c:\WINDOWS\System32\java.exe, which usually overrides most other settings.

这篇关于如何设置默认的Java安装/运行时(Windows)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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