java 我正在尝试设置我的 JAVA_HOME 路径以使用我的 javac.exe?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17296726/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
I'm trying to set my JAVA_HOME path to use my javac.exe?
提问by Joseph Safwat
I'm on Windows 7 and I'm trying to set my JAVA_HOME
path to use PhoneGap on android, when i create a project using the command line "cmd" it tells me that it can't find javac.exe? although i'm sure that I've set the variable right
我在 Windows 7 上,我正在尝试设置JAVA_HOME
在 android 上使用 PhoneGap 的路径,当我使用命令行“cmd”创建项目时,它告诉我它找不到 javac.exe?虽然我确定我已经正确设置了变量
here's my stuff:
这是我的东西:
Variable name: JAVA_HOME
Variable value: C:\Progra~1\Java\jdk1.7.0_17\bin
(I've also tried to use: C:\Progra~1\Java\jdk1.7.0_17\bin\javac.exe)
My javac.exe location on my laptop C:\Program Files\Java\jdk1.7.0_17\bin\javac.exe
我的笔记本电脑上的 javac.exe 位置 C:\Program Files\Java\jdk1.7.0_17\bin\javac.exe
and it still tells me that it can't locate the javac.exe
它仍然告诉我它无法找到 javac.exe
What I type to create the project and i meet this problem is this:
我输入的内容来创建项目,我遇到这个问题是这样的:
C:\Users\user>cd C:\Users\user\Desktop\phonegap-2.8.1\lib\android\bin
C:\Users\user\Desktop\phonegap-2.8.1\lib\android\bin>create.bat
Cannot locate javac.exe using the PATH environment variable.
Retry after adding directory containing javac.exe to the PATH variable.
Remember to open a new command window after updating the PATH variable.
Visit http://java.oracle.com if you need to install Java (JDK).
Also, i've tries restarting the windows and closing the command prompt and redownloading the JDK.
此外,我尝试重新启动 Windows 并关闭命令提示符并重新下载 JDK。
Thank You.
谢谢。
回答by Rapha?l
cmd
is using the values from the PATH
variable to locate javac
:
cmd
正在使用PATH
变量中的值来定位javac
:
set "PATH=%PATH%;C:\Program Files\Java\jdk1.7.0_17\bin"
For other softwares (Tomcat, Maven, etc.) JAVA_HOME
must indicate the root of your JDK :
其他软件(Tomcat、Maven等)JAVA_HOME
必须注明你的JDK根目录:
set "JAVA_HOME=C:\Program Files\Java\jdk1.7.0_17\"
No need to restart Windows. When using set
the changes are taken immediately.
无需重新启动 Windows。使用时set
立即进行更改。
If you choose to modify those variables in the Control Panel, you have to close and relaunch cmd
for the changes to take effect.
如果您选择在控制面板中修改这些变量,则必须关闭并重新启动cmd
以使更改生效。
回答by JREN
You have to add java
你必须添加java
C:\Program Files\Java\jdk1.7.0_17\bin
Note that your path may be different.
请注意,您的路径可能有所不同。
to your environment variables and restart your console.
到您的环境变量并重新启动您的控制台。
You can find how to set your variables here: http://www.itechtalk.com/thread3595.html
您可以在此处找到如何设置变量:http: //www.itechtalk.com/thread3595.html
回答by Ruchira Gayan Ranaweera
Set the JAVA_HOME Variable
设置 JAVA_HOME 变量
Right-click the My Computer icon on your desktop and select Properties.
Click the Advanced system settings. Click the
Environment Variables button. 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(C:\Program Files\Java\jdk1.7.0_17).
Click OK.
Click Apply Changes.
You might need to restart windows.
您可能需要重新启动 Windows。
回答by gaepi
I already had this error when I tried to create a new phonegap project for android but unfortunately I don't remember how exactly I have fixed this.
当我尝试为 android 创建一个新的 phonegap 项目时,我已经遇到了这个错误,但不幸的是我不记得我是如何解决这个问题的。
I don't know if you have followed the phonegap documentation so here is the link : new project, especially the part 3B (be careful about ;
in your PATH
).
If you don't know what to do now, maybe you should do it again step by step.
我不知道您是否遵循了 phonegap 文档,所以这里是链接:新项目,尤其是 3B 部分(;
在您的PATH
. 如果你现在不知道该做什么,也许你应该一步一步地再做一次。
回答by Hito_kun
May be a little old, but since this is the first goolge result, I might as well add a little something.
可能有点老了,不过既然是第一个goolge结果,还是补充一点吧。
You need to create the JAVA_HOME variable AND edit the PATH variable, adding ;%JAVA_HOME%\bin
(with a ;) so cmd and some other apps can actually use javac and the rest of the tools
您需要创建 JAVA_HOME 变量并编辑 PATH 变量,添加;%JAVA_HOME%\bin
(带有 ;)以便 cmd 和其他一些应用程序可以实际使用 javac 和其余工具
回答by Reimeus
Set the JAVA_HOME
environmental variable to
将JAVA_HOME
环境变量设置为
C:\Program Files\Java\jdk1.7.0_17
Press
按
Win + Break > Advanced System Settings > Environment Variables > System Variables
Modify/set JAVA_HOME
to the above. (No need to restart)
修改/设置JAVA_HOME
为上述。(无需重启)