-1

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 . enter image description here

  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. enter image description here

Botje
  • 26,269
  • 3
  • 31
  • 41
Shinichi
  • 85
  • 1
  • 4
  • 13

2 Answers2

1

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

Tashkhisi
  • 2,070
  • 1
  • 7
  • 20
0

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
Satish Pawar
  • 31
  • 1
  • 6
  • Poor example. `cls` isn't an external command at all, it is built into the shell. No binary, and nothing to do with the `PATH` whatsoever. – user207421 Aug 08 '20 at 09:49