1
votes

I am using java 12.0.2, JAVA_HOME is set as C:\Program Files\Java\jdk-12.0.2 and PATH is having %JAVA_HOME%\bin still when I try executing java command its giving me the error 'java' is not recognized as an internal or external command, operable program or batch file.
java and javac are part of JRE and JDK 12 doesn't have JRE now, so how to setup this. please don't relate this issue with old questions, until java8 it's fine but its not working now in windows 10. this is the JAVA_HOME

this is the Path entry

command prompt still showing error

path screenshot

3
When you get that error message, it means that the executable that you're trying to run (in this case 'JAVA') was not found. - Robert Harvey
This is a question about windows PATH management, not Java. I would first check that java is in %JAVA_HOME%\bin and then that this is really in the PATH that is in effect where you are trying to run it. We need more details about the environment you're having problems with. - asm
Try restarting your command line window or any application where you want to use the newly set PATH variables. - Dropout
@Dropout I have restarted the PC as well still the issue persists. - krishna thota
@krishnathota Are you sure that specific directory actually exists? - asm

3 Answers

2
votes

java and javac are part of JRE and JDK 12 doesn't have JRE now, so how to setup this.

After JDK 10, there is no separate JRE shipped and you do not need a separate JRE anymore. The JDK is enough.

I am using java 12.0.2, JAVA_HOME is set as C:\Program Files\Java\jdk-12.0.2 and PATH is having %JAVA_HOME%\bin

The space in the path may cause problems. I suggest you set C:\Program Files\Java\jdk-12.0.2\bin directly into PATH. Also, make sure to promote this entry to the top (beginning) so that this entry overrides the existing Java version (if any).

Last but not the least, start a new cmd window session to check java -version because the changes in the environment variables using the GUI does not become effective in already open cmd windows.

For any misconfiguration, if you can not make it work, download a fresh JDK and follow the instructions on the download page.

0
votes

Try removing any existing java paths and making sure your JAVA_HOME is correct. There is no JRE but the java command should work if your env vars are correct. It is most likely a configuration error so deleting old configuration and reconfiguring will probably hlep.

0
votes

The problem was caused by Python which was not allowing to execute java/javac commands. Once I uninstall the python everything worked fine.

I am still not sure what happened when I install Python as I explicitly didn't do anything except enabling the tick mark to setup the path variable while installing it.