简体   繁体   English

找不到Javac

[英]Javac is not found

I'm running Windows 8 and I can not get javac to work.我正在运行 Windows 8,但无法让 javac 工作。

I have set my PATH in environmental variables to我已将环境变量中的 PATH 设置为

C:\\Program Files (x86)\\Java\\jdk1.7.0_17\\bin

I have tried both with and without ';'我试过有和没有';' but to no avail.但无济于事。

I recently had this issue on my desktop and adding ;我最近在我的桌面上遇到了这个问题并添加了; worked but it's not in this case.工作,但它不是在这种情况下。

I have made sure that javac does exist in the bin too.我已经确保 javac 也确实存在于 bin 中。

Any suggestions on fixes would be greatly appreciated.任何关于修复的建议将不胜感激。

EDITS echo %PATH% gives:编辑 echo %PATH% 给出:

C:\Users\Arktri\Desktop>echo %PATH%

C:\Program Files (x86)\Intel\iCLS Client\;
C:\Program Files\Intel\iCLS Client\;
C:\Windows\system32;C:\Windows;
C:\Windows\System32\Wbem;
C:\Windows\System32\WindowsPowerShell\v1.0\;
C:\Program Files (x86)\Intel\OpenCL SDK\2.0\bin\x86;
C:\Program Files (x86)\Intel\OpenCL SDK\2.0\bin\x64;
C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;
C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;
C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;
C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;;
C:\Program Files (x86)\Java\jre7\bin

And the exact error is: 'javac' is not recognized as an internal or external command, operable program or batch file.确切的错误是:'javac' 不是内部或外部命令,也不是可运行的程序或批处理文件。

As far as I can see you have the JRE in your PATH , but not the JDK .据我所知,您的PATHJRE ,但没有JDK

From a command prompt try this:从命令提示符试试这个:

set PATH=%PATH%;C:\Program Files (x86)\Java\jdk1.7.0_17\bin

Then try javac again - if this works you'll need to permanently modify your environment variables to have PATH include the JDK too.然后再次尝试javac - 如果这有效,您将需要永久修改您的环境变量以使PATH包含JDK

  1. Go to my computer;转到我的电脑;
  2. Right click properties;右键单击属性;
  3. Go to advanced system settings;进入高级系统设置;
  4. Go to environment variables;转到环境变量;
  5. In user variables for user click on new(top new button, not on system variables);在用户的用户变量中点击新建(顶部新按钮,而不是系统变量);
  6. Set variable name as: Path将变量名称设置为: Path
  7. Set the value of that variable to: C:\\Program Files\\Java\\jdk1.7.0_76\\bin将该变量的值设置为: C:\\Program Files\\Java\\jdk1.7.0_76\\bin
  8. Click ok;点击确定;
  9. Click ok;点击确定;
  10. Click ok.单击确定。

Now you're set.现在你准备好了。 Type javac in cmd.在cmd中输入javac All javac options will be displayed.将显示所有 javac 选项。

I'm searched many answers that suggest me to type in cmd:我搜索了许多建议我输入 cmd 的答案:

set path = "%path%;c:program files\java\jdk1.7.0\bin"

but this is WRONG!但这是错误的!

the right solution is that you leave "set" and just type正确的解决方案是您离开“设置”并输入

path = %path%;c:program files\java\jdk1.7.0\bin

P/s: of course you have to replace "jdk1.7.0" folder by your current java version folder. P/s:当然你必须用你当前的java版本文件夹替换“jdk1.7.0”文件夹。 This works well on win 7 32bit, but I think it also works on win 8 - try it!这适用于 win 7 32bit,但我认为它也适用于 win 8 - 试试吧!

Start off by opening a cmd.exe session, changing directory to the "program files" directory that has the javac.exe executable and running .\\javac.exe.首先打开一个 cmd.exe 会话,将目录更改为具有 javac.exe 可执行文件并运行 .\\javac.exe 的“程序文件”目录。

If that doesn't work, reinstall java.如果这不起作用,请重新安装java。 If that works, odds are you will find (in doing that task) that you've installed a 64 bit javac.exe , or a slightly different release number of javac.exe , or in a different drive, etc. and selecting the right entry in your path will become child's play.如果javac.exe ,您很可能会发现(在执行该任务时)您已经安装了 64 位javac.exe ,或者版本号略有不同的javac.exe ,或者在不同的驱动器中,等等,然后选择正确的进入你的道路将成为孩子的游戏。

Only use the semicolon between directories in the PATH environment variable, and remember that in some systems, you need to log out and log back in before the new environment variable is accessible to all environments. PATH 环境变量中的目录之间只使用分号,记住在某些系统中,您需要注销并重新登录,然后所有环境都可以访问新的环境变量。

You don't have jdk1.7.0_17 in your PATH - check again.您的 PATH 中没有 jdk1.7.0_17 - 请再次检查。 There is only JRE which may not contain 'javac' compiler.只有 JRE 可能不包含“javac”编译器。

Besides it is best to set JAVA_HOME variable, and then include it in PATH.此外最好设置 JAVA_HOME 变量,然后将其包含在 PATH 中。

do this: 1. run CMD (WIN+R then type in CMD) 2. Type this:这样做: 1. 运行 CMD(WIN+R 然后输入 CMD) 2. 输入:

set PATH=%PATH%;设置路径=%PATH%; java installation path\\bin java安装路径\\bin

Replace "java installation path" with the directory JDK is installed in, such as C:\\Program Files (x86)\\Java.将“java安装路径”替换为JDK的安装目录,如C:\\Program Files (x86)\\Java。 Be sure to add the \\bin after the JDK directory, because this points to "javac" and "java" (BIN stands for "binaries")务必在JDK目录后添加\\bin,因为它指向“javac”和“java”(BIN代表“二进制文件”)

This way, you can run the Java compiler from anywhere.这样,您就可以从任何地方运行 Java 编译器。 It is impossible to CD to the JDK directory because it has a space in Program Files, and DOS will not let you CD to these directories.无法CD到JDK目录,因为它在Program Files中有空格,DOS不会让您CD到这些目录。

Easiest way: search for javac.exe in windows search bar.最简单的方法:在 Windows 搜索栏中搜索 javac.exe。 Then copy and paste the entire folder name and add it into the environmental variables path in advanced system settings.然后复制并粘贴整个文件夹名称,并将其添加到高级系统设置中的环境变量路径中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM