如何为 Eclipse/ANT 更改 JAVA.HOME [英] How to change JAVA.HOME for Eclipse/ANT

查看:28
本文介绍了如何为 Eclipse/ANT 更改 JAVA.HOME的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 ANT 脚本对 jar 文件进行签名.我知道这必须指向 JDK 目录才能运行 jarsigner.exe,但是当我回显 java.home 时它返回 JRE 目录.

I am trying to sign a jar file using an ANT script. I know this has to be pointed at the JDK directory for jarsigner.exe to run, but when I echo java.home it returns the JRE directory.

这对javac来说不是问题,因为我可以设置可执行路径.但是,signjar 不存在这种情况.

This isn't a problem for javac, because I can set the executable path. But, that does not exist for signjar.

如何更改 java.home 路径?当我右键单击 MyComputer 并转到:

How do I change the java.home path? When I right-click on MyComputer and go to:

属性 > 高级 > 环境变量

Properties > Advanced > Environment Variables

PATH"变量正确指向 JDK (C:\program files\java\jdk\bin).

The "PATH" variable is correctly pointed to the JDK (C:\program files\java\jdk\bin).

更新:更改下面建议的 PATH 变量后,文件现在可以正确签名.

Update: The file now signs correctly after changing the PATH variable suggested below.

推荐答案

在 Eclipse 中,Ant java.home 变量不是基于 Windows JAVA_HOME 环境变量.相反,它被设置为项目 JRE 的主目录.

In Eclipse the Ant java.home variable is not based on the Windows JAVA_HOME environment variable. Instead it is set to the home directory of the project's JRE.

要更改默认 JRE(例如将其更改为 JDK),您可以转到 Windows->Preferences... 并选择 Java->Installed JREs.

To change the default JRE (e.g. change it to a JDK) you can go to Windows->Preferences... and choose Java->Installed JREs.

要更改单个项目的 JRE,您可以转到 Project->Properties 并选择 Java Build Path 并选择 Libraries 选项卡.找到 JRE System Library 并单击它,然后选择 Edit 并选择所需的 JRE(或 JDK).

To change just a single project's JRE you can go to Project->Properties and choose Java Build Path and choose the Libraries tab. Find the JRE System Library and click it, then choose Edit and choose the JRE (or JDK) that you want.

如果这不起作用,那么在运行构建文件时,您可以选择 Run as->Ant Build... 并单击 JRE 选项卡,选择 分离 JRE 并在那里指定您想要的 JRE.

If that doesn't work then when running the build file you can choose Run as->Ant Build... and click the JRE tab, choose separate JRE and specify the JRE you want there.

这篇关于如何为 Eclipse/ANT 更改 JAVA.HOME的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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