如何在 Windows 7 上设置 java_home?

发布于 2024-08-28 16:06:01 字数 795 浏览 17 评论 0原文

我进入控制面板“系统”中的环境变量并创建了两个新变量,一个用于用户变量,一个用于系统变量。两者都被命名为 JAVA_HOME 并且都指向

C:\Sun\SDK\jdk\bin

但由于某种原因,我在运行 Java 命令时仍然收到以下错误...

BUILD FAILED
C:\Users\Derek\Desktop\eclipse\eclipse\glassfish\setup.xml:161: The following error  occurred while executing this line:
C:\Users\Derek\Desktop\eclipse\eclipse\glassfish\setup.xml:141: The following error occurred while executing this line:
C:\Users\Derek\Desktop\eclipse\eclipse\glassfish\setup.xml:137: Please set java.home to a JDK installation

Total time: 1 second
C:\Users\Derek\Desktop\eclipse\eclipse\glassfish>lib\ant\bin\ant -f setup.xml
Unable to locate tools.jar. Expected to find it in C:\Program Files\Java\jre6\lib\tools.jar
Buildfile: setup.xml

我该如何解决这个问题?

I went to the Environment Variables in 'System' in the control panel and made two new variables, one for user variables and one for system variables. Both were named JAVA_HOME and both pointing to

C:\Sun\SDK\jdk\bin

But for some reason, I still get the below error when running a Java command...

BUILD FAILED
C:\Users\Derek\Desktop\eclipse\eclipse\glassfish\setup.xml:161: The following error  occurred while executing this line:
C:\Users\Derek\Desktop\eclipse\eclipse\glassfish\setup.xml:141: The following error occurred while executing this line:
C:\Users\Derek\Desktop\eclipse\eclipse\glassfish\setup.xml:137: Please set java.home to a JDK installation

Total time: 1 second
C:\Users\Derek\Desktop\eclipse\eclipse\glassfish>lib\ant\bin\ant -f setup.xml
Unable to locate tools.jar. Expected to find it in C:\Program Files\Java\jre6\lib\tools.jar
Buildfile: setup.xml

How can I fix this problem?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(18

自演自醉 2024-09-04 16:06:01

查找JDK安装目录

首先您需要知道Java开发工具包的安装路径。

打开JDK的默认安装路径:

C:\Program Files\Java

应该有一个子目录,例如:

C:\Program Files\Java\jdk1.8.0_172

注意:只需将jdk的路径放在最后,不带/bin(正如很多地方所建议的那样)。例如 C:\Java\jdk1.8.0_172 而不是 C:\Java\jdk1.8.0_172\bin !


设置 JAVA_HOME 变量

获得 JDK 安装路径后:

  1. 右键单击桌面上的我的电脑图标,然后选择属性
  2. 单击高级选项卡,然后单击环境变量按钮。
  3. 系统变量下,单击新建。
  4. 输入变量名称JAVA_HOME
  5. 输入变量值作为 Java 开发工具包的安装路径。
  6. 单击确定
  7. 单击应用更改

注意:您可能需要重新启动 Windows

完整的文章位于我的博客上:在 Windows 中设置 JAVA_HOME 变量

Find JDK Installation Directory

First you need to know the installation path for the Java Development Kit.

Open the default installation path for the JDK:

C:\Program Files\Java

There should be a subdirectory like:

C:\Program Files\Java\jdk1.8.0_172

Note: one has only to put the path to the jdk without /bin in the end (as suggested on a lot of places). e.g. C:\Java\jdk1.8.0_172 and NOT C:\Java\jdk1.8.0_172\bin !


Set the JAVA_HOME Variable

Once you have the JDK installation path:

  1. Right-click the My Computer icon on your desktop and select Properties.
  2. Click the Advanced tab, then click the Environment Variables button.
  3. Under System Variables, click New.
  4. Enter the variable name as JAVA_HOME.
  5. Enter the variable value as the installation path for the Java Development Kit.
  6. Click OK.
  7. Click Apply Changes.

Note: You might need to restart Windows

The complete article is here, on my blog: Setting JAVA_HOME Variable in Windows.

ゞ记忆︶ㄣ 2024-09-04 16:06:01

对我有用的是将 %JAVA_HOME%\bin 添加到 Path 环境变量,其中 JAVA_HOME 环境变量指向 jdk 文件夹。

What worked for me was adding the %JAVA_HOME%\bin to the Path environment variable with the JAVA_HOME environment variable pointing to the jdk folder.

彼岸花似海 2024-09-04 16:06:01

您必须首先安装JDK 在您的系统中。

设置 Java Home

JAVA_HOME = C:\Program Files\Java\jdk1.7.0 [JDK 安装目录的位置]

获得 JDK 安装路径后:

  • 右键单击 上的“我的电脑”图标
  • 选择属性
  • 。单击屏幕左侧的高级系统设置选项卡,
  • 高级弹出窗口将打开。
  • 单击环境变量按钮。

在此处输入图像描述

  • 在“系统变量”下,单击“新建”。
  • 输入变量名称 JAVA_HOME。
  • 输入变量值作为 Java 开发工具包的安装路径。
  • 单击“确定”。
  • 单击应用更改。

设置系统变量PATH下的JAVA路径

= C:\Program Files\Java\jdk1.7.0; [用分号附加值]

检查此处

You have to first Install JDK in your system.

Set Java Home

JAVA_HOME = C:\Program Files\Java\jdk1.7.0 [Location of your JDK Installation Directory]

Once you have the JDK installation path:

  • Right-click the My Computer icon on
  • Select Properties.
  • Click the Advanced system setting tab on left side of your screen
  • Aadvance Popup is open.
  • Click on Environment Variables button.

enter image description here

  • Under System Variables, click New.
  • Enter the variable name as JAVA_HOME.
  • Enter the variable value as the installation path for the Java Development Kit.
  • Click OK.
  • Click Apply Changes.

Set JAVA Path under system variable

PATH= C:\Program Files\Java\jdk1.7.0; [Append Value with semi-colon]

check here

单身狗的梦 2024-09-04 16:06:01

在 cmd 中(暂时用于该 cmd 窗口):

set JAVA_HOME="C:\\....\java\jdk1.x.y_zz"

echo %JAVA_HOME%

set PATH=%PATH%;%JAVA_HOME%\bin

echo %PATH%

In cmd (temporarily for that cmd window):

set JAVA_HOME="C:\\....\java\jdk1.x.y_zz"

echo %JAVA_HOME%

set PATH=%PATH%;%JAVA_HOME%\bin

echo %PATH%
世界和平 2024-09-04 16:06:01

您需要将其设置为 C:\Sun\SDK\jdk (假设这是安装 JDK 的位置 - 它不是默认值) - 不要将 \bin 放入 C: \Sun\SDK\jdk\bin

如果您的应用程序仅在您以当前用户身份登录时运行,则将其放入用户变量中 - 如果它需要为系统上的所有用户运行,则将其放入系统变量中。

您可能还需要将 %JAVA_HOME%\bin 添加到路径中(这还取决于您是仅从用户运行它还是从所有用户运行它,包括系统)

You need to set it to C:\Sun\SDK\jdk (Assuming that is where the JDK is installed - It is not the default) - Do not put the \bin in C:\Sun\SDK\jdk\bin.

If your app only runs when you are logged in as the current user then put it in the user variables - If it needs to run for all users on your system then put it in System variables.

You might also need to add %JAVA_HOME%\bin to the path also (Also it depends on whether you run it from just the user or from all users, including System)

べ映画 2024-09-04 16:06:01

http://javahowto.blogspot.com/2006/05/javahome-vs -javahome.html

控制面板> Java,Java 选项卡,单击查看按钮。在运行时参数中,输入:

-Djava.home=YOUR_PATH_HERE

或者,当您执行 Java 时,您可以将该命令行开关添加到命令中:

java -Djava.home=PATH SomeJavaApp

http://javahowto.blogspot.com/2006/05/javahome-vs-javahome.html

Control Panel > Java, Java tab, click the View button. In Runtime Parameters, put:

-Djava.home=YOUR_PATH_HERE

Or when you execute Java you can add that command line switch to the command:

java -Djava.home=PATH SomeJavaApp
牵你手 2024-09-04 16:06:01

一张图片就可以解决这个问题。
输入图像描述这里

了解更多

One Image can fix this issue.
enter image description here

For More

森林散布 2024-09-04 16:06:01

对于那些仍然被这个问题困扰的人(我尝试了上述所有建议)——

如果您使用的是 64 位版本的 Windows 并且安装了 32 位 JDK,除了调整 PATH 变量,您可能还需要调整 registry 变量。

我抓狂了,正确设置了我的 PATH 变量 - 仍然无济于事 - 然后只在我的注册表中找到“空出的”Java 条目,这似乎是修复“失火”的死胡同Java 运行时环境。

通过使用 Process Monitor 来观察我试图启动的程序,以便嗅出它在 Java(运行时环境)注册表中查找的位置,我成功地发现它正在查找 < Strong>32 位 版本的注册表项,位于 HKEY_LOCAL_MACHINE\SOFTWARE\**Wow6432Node**\JavaSoft\Java Runtime Environment 中。

在该项中,您应该找到已安装的不同 Java 版本(过去和/或现在)的子项。单击最新版本的子项(例如,我的子项当前为1.7.0_25)。单击该子项后,您将看到右侧列出的注册表字符串值,特别是 JavaHomeRuntimeLib。您需要修改这两个值以分别反映当前文件夹和jvm.dll 文件。

例如,在我的例子中,这些值(之前)分别设置在 C:\Program Files (x86)\Java\jre7C:\Program Files (x86)\Java\ jre7\bin\client\jvm.dll 在我的机器上不存在。我必须将它们更新到 C:\Program Files (x86)\Java\jdk1.7.0_25\jreC:\Program Files (x86)\Java 的当前文件夹和文件\jdk1.7.0_25\jre\bin\client\jvm.dll

同样,这完全取决于您安装的 Java 版本(JDK 和/或 JRE)(32 位或 64 位)以及您使用的操作系统类型(32 位或 64 位)。只需知道它们反映在注册表中的不同位置即可(例如 32 位应用程序的 Wow6432Node,在我的例子中,32 位 JDK 安装在 64 位计算机上)。

现在我已经更新了这两个注册表值,我的程序可以完美运行,不再出现问题或抱怨缺少 Java 运行时环境(源于注册表)。

For those who are still stumped with this problem (I tried all the above suggestions) --

If you're on a 64-bit version of Windows and you've installed the 32-bit JDK, besides adjusting PATH variables, you may need to adjust registry variables, too.

I was pulling my hair out, having correctly set my PATH variables -- still to no avail -- and then only finding "vacated" Java entries in my registry, seemingly a deadend of fixing the "misfiring" Java Runtime Environment.

By using Process Monitor to watch the program I was trying to get started, in order to sniff out where it was looking in the registry for Java (Runtime Environment), I triumphantly discovered that it's looking in the 32-bit version of registry entries, found in HKEY_LOCAL_MACHINE\SOFTWARE\**Wow6432Node**\JavaSoft\Java Runtime Environment.

Within that key, you should find subkeys of different Java versions installed (past and/or present). Click on the subkey of the latest version (my subkey is currently 1.7.0_25, for example). After clicking on that subkey, you'll see registry string values listed on the right, and particularly, JavaHome and RuntimeLib. You need to modify the values of those two values to reflect the both the current folder and jvm.dll file, respectively.

For example, in my case, the values were (previously) respectively set at C:\Program Files (x86)\Java\jre7 and C:\Program Files (x86)\Java\jre7\bin\client\jvm.dll which are nonexistent on my machine. I had to update these to the current folder and file of C:\Program Files (x86)\Java\jdk1.7.0_25\jre and C:\Program Files (x86)\Java\jdk1.7.0_25\jre\bin\client\jvm.dll.

Again, this will depend entirely on both what version of Java (JDK and/or JRE) you have installed -- 32 or 64-bit -- and what type of operating system you're on -- 32 or 64-bit. Just know that they're reflected in different locations within the registry (like the Wow6432Node for 32 bit applications, in my case with the 32-bit JDK installed on a 64-bit machine).

Now that I've updated those two registry values, my program runs flawlessly, with no more hiccups or complaints about a missing Java Runtime Environment (stemming from the registry).

你如我软肋 2024-09-04 16:06:01

这是从 www.java 设置 Java 环境的官方解决方案 .com - 此处

有适用于 Windows 7、Windows Vista、Windows XP、Linux/Solaris 和其他 shell 的解决方案。


例子

Windows 7

  1. 从“开始”菜单中选择“计算机”
  2. 从上下文菜单中选择“系统属性”
  3. 点击高级系统设置->高级选项卡
  4. 单击“环境变量”,在“系统变量”下找到 PATH,然后单击它。
  5. 在“编辑”窗口中,通过将类的位置添加到 PATH 值来修改 PATH。如果没有 PATH 项,可以选择添加一个新变量,并添加 PATH 作为名称,类的位置作为值。
  6. 重新打开命令提示符窗口,然后运行 ​​Java 代码。

This is the official solution for setting the Java environment from www.java.com - here.

There are solutions for Windows 7, Windows Vista, Windows XP, Linux/Solaris and other shells.


Example

Windows 7

  1. Select Computer from the Start menu
  2. Choose System Properties from the context menu
  3. Click Advanced system settings -> Advanced tab
  4. Click on Environment Variables, under System Variables, find PATH, and click on it.
  5. In the Edit windows, modify PATH by adding the location of the class to the value for PATH. If you do not have the item PATH, you may select to add a new variable and add PATH as the name and the location of the class as the value.
  6. Reopen Command prompt window, and run your Java code.
晌融 2024-09-04 16:06:01

Windows 7

  1. 使用 Explorer(不是 Internet Explorer!)转至控制面板\所有控制面板项目\用户帐户

    • 单击“开始”按钮

      开始

    • 点击您的图片

      点击照片

  2. 更改我的环境变量

    更改我的环境变量

  3. 新...

    新

    (如果您没有足够的权限将其添加到“系统变量”部分,请将其添加到“用户变量”部分)

  4. 添加 JAVA_HOME 作为变量名称,将 JDK 位置添加为变量值 >好的

    编辑系统变量 ok

测试:

  • 打开一个控制台(cmd)
  • 类型set JAVA_HOME
    • 预期输出:JAVA_HOME=C:\Program Files\Java\jdk1.8.0_60

Windows 7

  1. Go to Control Panel\All Control Panel Items\User Accounts using Explorer (not Internet Explorer!)

    or

    • click on the Start button

      start

    • click on your picture

      clickOnPhoto

  2. Change my environment variables

    Change my environment variables

  3. New...

    new

    (if you don't have enough permissions to add it in the System variables section, add it to the User variables section)

  4. Add JAVA_HOME as Variable name and the JDK location as Variable value > OK

    edit system variable ok

Test:

  • open a new console (cmd)
  • type set JAVA_HOME
    • expected output: JAVA_HOME=C:\Program Files\Java\jdk1.8.0_60
零度℉ 2024-09-04 16:06:01

我们需要区分这里互换讨论的两个环境变量。一是JAVA_HOME变量。另一个是Path变量。任何引用 JAVA_HOME 变量的进程都会寻找 JDK 的搜索路径,而不是 JRE。 JAVA_HOME 变量的使用并不意味着 Java 编译器本身。编译器知道它自己的位置。该变量旨在让其他软件更轻松地找到编译器。该变量通常由 IDE 软件使用,以便从 Java 源代码编译和构建应用程序。相比之下,Windows CMD 解释器和许多其他第一方和第三方软件引用 Path 变量,而不是 JAVA_HOME 变量。

用例 1:从 CMD 编译

例如,如果您没有使用任何 IDE 软件,而您只是希望能够从 CMD 进行编译,独立于当前的工作目录,那么您可以执行以下操作:想要的是正确设置 Path 变量。就您而言,您甚至不需要 JAVA_HOME 变量。因为 CMD 使用 Path 而不是 JAVA_HOME 来定位 Java 编译器。

用例 2:从 IDE 编译

但是,如果您正在使用某些 IDE 软件,那么您必须首先查看文档。它可能需要设置 JAVA_HOME,但也可能出于相同目的使用另一个变量名称。多年来事实上的标准一直是 JAVA_HOME,但情况可能并非总是如此。

用例 3:从 IDE 和 CMD 编译

如果除了 IDE 软件之外,您还希望能够从 CMD 进行编译,而与当前工作目录无关,那么另外 添加到 JAVA_HOME 变量中,您可能还需要将 JDK 搜索路径附加到 Path 变量中。

JAVA_HOME 与 Path

如果您的问题与编译 Java 相关,那么您需要检查 JAVA_HOME 变量和 Path(如果适用)。如果您的问题与运行 Java 应用程序有关,那么您需要检查 Path 变量。

路径变量在所有操作系统中通用。因为它是由系统定义的,并且是用于定位 JRE 的默认变量,所以运行 Java 应用程序几乎不会出现任何问题。尤其是在 Windows 上,软件安装程序通常会为您设置好一切。但是,如果您手动安装,最安全的做法可能是完全跳过 JAVA_HOME 变量,而仅使用 Path 变量来完成所有内容(对于 JDK 和 JRE)。任何最新版本的 IDE 软件都应该能够获取并使用它。

符号链接

符号链接可以提供另一种通过搭载现有环境变量来引用 JDK 搜索路径的方法。

我不确定以前版本的 Oracle/Sun JDK/JRE 版本,但至少 jdk1.8.0_74 的安装程序将搜索路径 C:\ProgramData\Oracle\Java\javapath 附加到路径变量,将其放在字符串值的开头。该目录包含指向 JRE 目录中的 java.exe、javaw.exe 和 javaws.exe 的符号链接。

因此,至少对于 Java 8 JDK,大概是 Java 8 JRE 独立版,不需要为 JRE 进行环境变量配置。只要使用安装包来设置就可以了。但是,您的 Windows 安装可能会有所不同。请注意,Oracle JRE 与 JDK 捆绑在一起。

如果您发现您的 Java JDK 配置使用了错误版本的编译器,或者它似乎神奇地工作,而没有明确定义(没有施咒),那么您的环境变量中可能有一个符号链接。因此您可能需要检查符号链接。

We need to make a distinction between the two environment variables that are discussed here interchangeably. One is the JAVA_HOME variable. The other is the Path variable. Any process that references the JAVA_HOME variable is looking for the search path to the JDK, not the JRE. The use of JAVA_HOME variable is not meant for the Java compiler itself. The compiler is aware of its own location. The variable is meant for other software to more easily locate the compiler. This variable is typically used by IDE software in order to compile and build applications from Java source code. By contrast, the Windows CMD interpreter, and many other first and third party software references the Path variable, not the JAVA_HOME variable.

Use case 1: Compiling from CMD

So for instance, if you are not using any IDE software, and you just want to be able to compile from the CMD, independent of your current working directory, then what you want is to set the Path variable correctly. In your case, you don't even need the JAVA_HOME variable. Because CMD is using Path, not JAVA_HOME to locate the Java compiler.

Use case 2: Compiling from IDE

However, if you are using some IDE software, then you have to look at the documentation first of all. It may require JAVA_HOME to be set, but it may also use another variable name for the same purpose. The de-facto standard over the years has been JAVA_HOME, but this may not always be the case.

Use case 3: Compiling from IDE and CMD

If in addition to the IDE software you also want to be able to compile from the CMD, independent of your current working directory, then in addition to the JAVA_HOME variable you may also need to append the JDK search path to the Path variable.

JAVA_HOME vs. Path

If your problem relates to compiling Java, then you want to check the JAVA_HOME variable, and Path (where applicable). If your problem relates to running Java applications, then you want to check your Path variable.

Path variable is used universally across all operating systems. Because it is defined by the system, and because it's the default variable that's used for locating the JRE, there is almost never any problem running Java applications. Especially not on Windows where the software installers usually set everything up for you. But if you are installing manually, the safest thing to do is perhaps to skip the JAVA_HOME variable altogether and just use the Path variable for everything, for both JDK and the JRE. Any recent version of an IDE software should be able to pick that up and use it.

Symlinks

Symbolic links may provide yet another way to reference the JDK search path by piggybacking one of the existing environment variables.

I am not sure about previous versions of Oracle/Sun JDK/JRE releases, but at least the installer for jdk1.8.0_74 appends the search path C:\ProgramData\Oracle\Java\javapath to the Path variable, and it puts it at the beginning of the string value. This directory contains symbolic links to the java.exe, javaw.exe and javaws.exe in the JRE directory.

So at least with the Java 8 JDK, and presumably the Java 8 JRE standalone, no environment variable configuration needs to be done for the JRE. As long as you use the installer package to set it up. There may be differences on your Windows installation however. Note that the Oracle JRE comes bundled with the JDK.

If you ever find that your Java JDK configuration is using the wrong version of the compiler, or it appears to be working by magic, without being explicitly defined so (without casting the spell), then you may have a symlink somewhere in your environment variables. So you may want to check for symlink.

只有一腔孤勇 2024-09-04 16:06:01

转到我的电脑(这台电脑)->右键->选择属性->高级系统设置->环境变量->在系统变量中点击“新建”按钮,在变量名中写入JAVA_HOME,路径为C:\Program Files\ Java\jdk1.8.0_131 变量值中存在 jdk->单击“确定”。

设置 JAVA_HOME 后关闭并重新打开命令提示符。有时更改不会反映在设置 JAVA_HOME 之前打开的 cmd 中。

您还可以通过终端本身设置 JAVA_HOME:
SET JAVA_HOME="C:\Program Files (x86)\Java\jdk1.8.0_131"

goto Mycomputer(This PC) -> rightclick ->select properties -> Advanced system settings -> environment variables-> in system variables click "New" button and write JAVA_HOME in variable name and path C:\Program Files\Java\jdk1.8.0_131 were jdk is present in variable value-> click ok.

close and reopen the command prompt after setting JAVA_HOME. Sometimes changes does not reflect in the cmd opened before setting the JAVA_HOME.

you can also set JAVA_HOME through terminal itself:
SET JAVA_HOME="C:\Program Files (x86)\Java\jdk1.8.0_131"

寄离 2024-09-04 16:06:01

在 Eclipse 中:Window->Preferences->Java->Installed JREs

使用搜索功能确保列出了最新的 Java 安装;然后确保它是被检查的那个。这应该是 JDK 而不是 JRE。

In Eclipse: Window->Preferences->Java->Installed JREs

Use the search feature to make sure your latest Java installation is listed; then make sure it is the one that is checked. This should be a JDK not a JRE.

深者入戏 2024-09-04 16:06:01

将 Java 目录添加到 PATH 变量时,您可能希望将其放在其开头。我遇到了一个问题,将 Java 目录放在 PATH 的末尾是行不通的。经过检查,我在我的 Windows\System32 目录中找到了 java.exe ,当你的文件中有多个同名文件时,看起来第一个获胜。 路径...

While adding your Java directory to your PATH variable, you might want to put it right at the beginning of it. I've had the problem, that putting the Java directory at the end of the PATH would not work. After checking, I've found java.exe in my Windows\System32 directory and it looks like the first one wins, when there are several files with the same name in your PATH...

时光暖心i 2024-09-04 16:06:01

以管理员身份运行 Eclipse

这解决了我的问题。我仍在挖掘其背后的逻辑。

Run Eclipse as Administrator.

That solved my problem. I'm still digging for the logic behind it.

ˇ宁静的妩媚 2024-09-04 16:06:01

如果安装jdk后没有重新启动计算机,只需重新启动计算机即可。

如果您想制作一个便携式 java 并在使用 java 之前设置路径,只需制作一个我在下面解释的批处理文件。

如果您想在计算机启动时运行此批处理文件,只需将批处理文件快捷方式放在启动文件夹中即可。在 Windows 7 启动文件夹中,“C:\Users\user\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup”

创建一个批处理文件,如下所示:

set Java_Home=C:\Program Files\Java\jdk1.8.0_11
set PATH=%PATH%;C:\Program Files\Java\jdk1.8.0_11\bin

注意:
java_homepath 是变量。您可以根据需要创建任何变量。
例如,设置 amir=good_boy,您可以通过 %amir% 查看 amir,或者通过 %java_home% 查看 java_home

if you have not restarted your computer after installing jdk just restart your computer.

if you want to make a portable java and set path before using java, just make a batch file i explained below.

if you want to run this batch file when your computer start just put your batch file shortcut in startup folder. In windows 7 startup folder is "C:\Users\user\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup"

make a batch file like this:

set Java_Home=C:\Program Files\Java\jdk1.8.0_11
set PATH=%PATH%;C:\Program Files\Java\jdk1.8.0_11\bin

note:
java_home and path are variables. you can make any variable as you wish.
for example set amir=good_boy and you can see amir by %amir% or you can see java_home by %java_home%

倾`听者〃 2024-09-04 16:06:01

经过几个小时的解决这里的大多数解决方案后,我只需安装 32 位 JDK 就解决了这个问题。

After hours of work around most of the solutions here, the problem was solved for me just by installing 32-bit JDK.

〃温暖了心ぐ 2024-09-04 16:06:01

您可能想查看 Windows/System32 文件夹中的以下文件:
- java.exe
- javaw.exe
- javaws.exe

因为路径变量包含这些文件,所以你可能会很头疼地试图弄清楚为什么 java -version 或 javac -version 一直指向旧的 JAVA_HOME:重命名这些文件,去掉带下划线的扩展名, 例如。然后,您只需创建 JAVA_HOME 变量,将其添加到路径变量(例如%JAVA_HOME%)并附加“\bin”粒子。这样,您只需更改指向不同 JRE 或 JDK 的 JAVA_HOME 变量,并通过设置 JAVA_HOME 即可多次安装 java。

这也意味着最好手动安装 Java,无需安装程序,这样您就可以使用它。

You may wanna look into Windows/System32 folder for the following files:
- java.exe
- javaw.exe
- javaws.exe

Because, the path variable is including these files, you can get a headache trying to figure out why the java -version or javac -version keeps pointing to the old JAVA_HOME: rename those files, take out the extension with an underscore, for instance. And then, you only will have to create the JAVA_HOME variable, add it to the path variable (e.g., %JAVA_HOME%) and append the "\bin" particle. This way you need to only change the JAVA_HOME variable pointing to different JRE or JDK and have multiple installations of java just by setting JAVA_HOME.

This also means that it is better to install Java manually, without an installer, so you are able to toy with it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文