Java 如何修复此程序中的编译器错误?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21715216/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-13 10:14:24  来源:igfitidea点击:

How to fix the compiler error in this program?

javacompiler-constructionjgrasp

提问by MTNLegit

So i'm a student in high school new to the Java language and i'm using this program called jgrasp, which we use to program java. I just got the program for home to try to finish off a lab I was working on and when I compile, this shows up:

所以我是一名高中生,刚接触 Java 语言,我正在使用这个名为 jgrasp 的程序,我们用它来编写 Java 程序。我刚刚拿到了回家的程序,试图完成我正在做的一个实验室,当我编译时,它出现了:

 ----jGRASP exec: javac -g EqualToThree.java

 ----jGRASP wedge2 error: command "javac" not found.
 ----   This command must be in the current working directory or
 ----   on the current system PATH or jGRASP PATH to use this function.
 ----   System + jGRASP PATH is "C:\Program       Files\Java;C:\WINDOWS\system32;C:\WINDOWS\system32\wbem;C:\Program Files\QuickTime\QTSystem;C:\Documents and Settings\Andrew\My Documents\Downloads;C:\WINDOWS\system32;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\QuickTime\QTSystem\".

 ----   Use   Settings > PATH/CLASSPATH > Workspace   (PATHS tab)
 ----   to add directories to the jGRASP PATH.

 ----jGRASP: operation complete.

I just recently upgraded my java to the latest version, and I honestly have no idea how to fix this. I did go to the class path, and selected the selected files it wants, but still no luck. Any idea?

我最近刚刚将我的 java 升级到最新版本,老实说我不知道​​如何解决这个问题。我确实去了类路径,并选择了它想要的选定文件,但仍然没有运气。任何的想法?

回答by Grant

I had a similar problem, I do not know if it is specific to windows 7 or what.

我有一个类似的问题,我不知道它是否特定于 Windows 7 或什么。

I had installed several copies of the JDK thinking that would automatically fix it. It did not. Jgrasp somehow had multiple paths to the Java Compiler (javac), and the first one it went to was the JRE.

我已经安装了几个 JDK 副本,认为会自动修复它。它没。不知何故,Jgrasp 有多个通往 Java 编译器 (javac) 的路径,而它访问的第一个路径是 JRE。

I solved it this way:

我是这样解决的:

  1. I went to SETTINGS/ PATH/CLASSPATH / PATH(tab) / PATH(tab)
  2. click New
  3. (in a seperate windows explorer window I verified the correct path to the JDK) and added C:\Program Files\Java\jdk1.8.0_11\bin
  4. click Apply
  5. click Ok
  1. 我去了 SETTINGS/PATH/CLASSPATH/PATH(tab)/PATH(tab)
  2. 点击新建
  3. (在单独的 Windows 资源管理器窗口中,我验证了 JDK 的正确路径)并添加了 C:\Program Files\Java\jdk1.8.0_11\bin
  4. 单击应用
  5. 单击确定

That fixed it, and made the bad frustration go away.

这解决了它,并使糟糕的挫败感消失了。