如何在 Windows 7 上设置 java_home? [英] How to set java_home on Windows 7?

查看:28
本文介绍了如何在 Windows 7 上设置 java_home?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我转到控制面板中系统"中的环境变量并创建了两个新变量,一个用于用户变量,一个用于系统变量.两者都被命名为 JAVA_HOME 并且都指向

<块引用>

C:SunSDKjdkin

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

构建失败C:UsersDerekDesktopeclipseeclipseglassfishsetup.xml:161: 执行此行时出现以下错误:C:UsersDerekDesktopeclipseeclipseglassfishsetup.xml:141: 执行此行时出现以下错误:C:UsersDerekDesktopeclipseeclipseglassfishsetup.xml:137:请将 java.home 设置为 JDK 安装总时间:1秒C:UsersDerekDesktopeclipseeclipseglassfish>libantinant -f setup.xml无法找到 tools.jar.预计在 C:Program FilesJavajre6lib	ools.jar 中找到它构建文件:setup.xml

我该如何解决这个问题?

解决方案

查找JDK安装目录

首先您需要知道 Java Development Kit 的安装路径.

打开JDK的默认安装路径:

C:Program FilesJava

应该有一个子目录,如:

C:Program FilesJavajdk1.8.0_172

<块引用>

注意:最后只需要放上jdk的路径,而没有/bin(很多地方都建议这样做).例如C:Javajdk1.8.0_172 而不是 C:Javajdk1.8.0_172in !

<小时>

设置 JAVA_HOME 变量

获得JDK安装路径后:

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

<块引用>

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

完整的文章在这里,在我的博客上:在 Windows 中设置 JAVA_HOME 变量.

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:SunSDKjdkin

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

BUILD FAILED
C:UsersDerekDesktopeclipseeclipseglassfishsetup.xml:161: The following error  occurred while executing this line:
C:UsersDerekDesktopeclipseeclipseglassfishsetup.xml:141: The following error occurred while executing this line:
C:UsersDerekDesktopeclipseeclipseglassfishsetup.xml:137: Please set java.home to a JDK installation

Total time: 1 second
C:UsersDerekDesktopeclipseeclipseglassfish>libantinant -f setup.xml
Unable to locate tools.jar. Expected to find it in C:Program FilesJavajre6lib	ools.jar
Buildfile: setup.xml

How can I fix this problem?

解决方案

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 FilesJava

There should be a subdirectory like:

C:Program FilesJavajdk1.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:Javajdk1.8.0_172 and NOT C:Javajdk1.8.0_172in !


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.

这篇关于如何在 Windows 7 上设置 java_home?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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