“javac is not recognized as internal command” 可翻译为: “javac 被识别为内部命令”

huangapple go评论73阅读模式
英文:

javac is not recognized as internal command

问题

我的当前系统配置是 -

  • Netbeans 12.0
  • JDK 14.0.2
  • Windows 10 (64位)
  1. 我手动将环境变量添加到PATH中,即C:\Program Files\Java\jdk-14.0.2\bin。

  2. 我尝试使用命令行添加,同时将JAVA_HOME作为一个新变量添加,其值为C:\Program Files\Java\jdk-14.0.2。
    “javac is not recognized as internal command” 可翻译为:
“javac 被识别为内部命令”

  3. 我使用set命令来执行此过程,即set path="%path%;C:\Program Files\Java\jdk-14.0.2\bin"。此外,我还尝试过不使用set关键字的相同命令。

  4. 由于javah命令在jdk>8的版本中已被弃用,我也尝试使用javac -h命令。

  5. 我还尝试安装了JDK v. 8.0.2,而不是当前的版本。

  6. 尽管bin文件夹中没有javah.exe文件,但有javac.exe文件。

  7. 我已经多次卸载并重新安装了JDK和Netbeans。

我目前正在使用Netbeans IDE和C/C++插件进行JNI开发(我已成功安装了Cygwin和必要的文件扩展以进行构建。虽然我不知道它们如何影响这个问题,但我认为我应该添加这一点)。
我希望与'javah'一起使用的命令是从Java类创建C头文件的命令,即'javah -o JNIDemoJava.h -classpath JNIDemoJava/build/classes jnidemojava.Main'。
但由于这个错误,我已经卡住了几天。请协助解决。
“javac is not recognized as internal command” 可翻译为:
“javac 被识别为内部命令”

英文:

My current system config is -

  • Netbeans 12.0

  • JDK 14.0.2

  • Windows 10 (64bit)

  1. I have added the environmental variable in PATH manually i.e. C:\Program Files\Java\jdk-14.0.2\bin.

  2. I tried adding using cmd as well. As well as adding the JAVA_HOME as a new variable with value as C:\Program Files\Java\jdk-14.0.2 .
    “javac is not recognized as internal command” 可翻译为:
“javac 被识别为内部命令”

  3. I have used the set command to do this process i.e. set path = "%path%;"C:\Program Files\Java\jdk-14.0.2\bin". Also, I have used the same command without the set keyword.

  4. Since javah command was deprecated for versions of jdk>8, I have tried to use javac -h command as well.

  5. I have also tried to install JDK v. 8.0.2 instead of the current one.

  6. Although there's no javah.exe file in the bin folder, there is however javac.exe file.

  7. I have uninstalled and reinstalled JDK and Netbeans quite a few times.

I am currently working on JNI with Netbeans IDE and C/C++ plugin. (I have successfully installed Cygwin and necessary extension for the file to build. Although I don't know how they affect this problem, still I thought I should add this).
The command I wish to use with 'javah' is the one used for creating a C header from a Java class i.e. 'javah -o JNIDemoJava.h -classpath JNIDemoJava/build/classes jnidemojava.Main'.

But due to this error, I have been stuck for a few days. Please do assist.
“javac is not recognized as internal command” 可翻译为:
“javac 被识别为内部命令”

答案1

得分: 1

以下是翻译好的部分:

以下是您可以设置路径变量的临时方式(仅可在相同的命令行中使用):

您应该这样做:(注意 =)

set PATH=C:\Program Files\Java\jdk-14.0.2\bin

如果您已正确设置了JAVA_HOME变量,可以这样做:

set PATH="%JAVA_HOME%\bin"

要永久设置此项,请阅读此帖子:

https://javatutorial.net/set-java-home-windows-10

英文:

Following way you can set Path variable temporary(it can only be used in the same command line):

You should do it this way:(notice =)

set PATH=C:\Program Files\Java\jdk-14.0.2\bin

And if you set JAVA_HOME variable correctly you can do it this way:

set PATH="%JAVA_HOME%\bin"

For setting this permanently read this post :

https://javatutorial.net/set-java-home-windows-10

答案2

得分: 0

我们应该知道这个原因:

  1. 我们的操作系统带有一组预定义的工具和实用程序。当我们尝试在Windows命令行中执行命令e.g. cls时,它已经存在于系统路径变量中,操作系统将引用相应的cls二进制文件来执行该命令。

  2. 然而,当我们安装任何第三方工具/软件时,路径变量不会相应地更新。

  3. 当我们在系统上安装不同版本的Java时,安装将在不同的目录中进行。例如,Windows上的JDK安装目录将是
    C:\Program Files\Java\jdk1.8.0_161

  4. 类似地,Windows上的JRE安装目录将是JDK安装目录的子目录:
    C:\Program Files\Java\jre1.8.0_161

  5. 我们需要更新操作系统的路径变量,以指向适当的目录。如果我们设置了JDK的路径,它将执行JDK bin目录中的二进制文件。

解决方案

  • 我们需要将JDKJRE特定版本的目录位置更新到PATH环境变量中。
  • 在这种情况下,使用以下命令来设置JAVA_PATH:
    set path=C:\Program Files\Java\jdk-14.0.2\bin
英文:

We should know the reason for this

  1. Our OS comes with a predefined (built-in)set of tools and utilities. When we try to execute the command e.g. cls in the Windows command line then it is already present in system path variable and os will refer the corresponding binary of cls to execute the command.

  2. However, when we install any third party tool/software then path variable is not updated accordingly.

  3. When we install different versions of java on your system then installations go to different directories. E.g. JDK installation directory for Windows will be
    C:\Program Files\Java\jdk1.8.0_161

  4. Similarly, JRE installation directory for Windows will be JDK installation directory for Windows will be
    C:\Program Files\Java\jre1.8.0_161

  5. We need to update the path variable of OS to point to the appropriate directory. If we set the path of JDK then it will execute a binary from JDK bin directory.

Solution

  • we need to update JDK or JRE version specific directory location into PATH Environment variable.
  • In this case use
    set path=C:\Program Files\Java\jdk-14.0.2\bin to set JAVA_PATH

huangapple
  • 本文由 发表于 2020年8月8日 15:41:09
  • 转载请务必保留本文链接:https://go.coder-hub.com/63312947.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定