gpt4 book ai didi

java - 如何在 Windows 7 上设置 java_home?

转载 作者:bug小助手 更新时间:2023-10-28 01:35:59 24 4
gpt4 key购买 nike

我在控制面板的“系统”中的环境变量中创建了两个新变量,一个用于用户变量,一个用于系统变量。两者都被命名为 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

我该如何解决这个问题?

最佳答案

查找 JDK 安装目录

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

打开JDK的默认安装路径:

C:\Program Files\Java

应该有一个像这样的子目录:

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 !


设置 JAVA_HOME 变量

一旦你有了 JDK 安装路径:

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

Note: You might need to restart Windows

完整的文章在这里,在我的博客上:Setting JAVA_HOME Variable in Windows .

关于java - 如何在 Windows 7 上设置 java_home?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2619584/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com