I have Java installed on my machine (the JRE is under C:\\Program Files\\Java
) but I can\'t run any java command from the Windows PowerShell command prompt.
I fixed this problem by reinstalling Git-2.8.2-64-bit.exe and following these instructions! https://learn.adafruit.com/windows-tools-for-the-electrical-engineer/git-plus-command-line-tools
I then added the code mentioned above c:\Program Files\Java\jdk-11.0.3\bin by navigating to control panel /system/Advanced tab Click on the Environment Variables then the system's variables and looked for Path then edited it. then added c:\Program Files\Java\jdk-11.0.3\bin and all is working for me now in a Windows PowerShell and also a MinGW64! See images of it working! Windows power shell
Make 2 environment variable changes:
1. Add a JAVA_HOME variable equal to something like: C:\Java\JDK1.7.0_25_x64
2. Add %JAVA_HOME%\bin to the beginning of your PATH variable.
Then, start a brand new shell to see if the changes were applied.
If the environment variable is set or you have sourced the environment appropriately, the issue is executing a file in a shell:
javac .\HelloWorld.java //That is a file, so it can be ./
java HelloWorld //Not the correct file name, so it will not execute, and so must call it as in MSDOS
You cannot .\
on the HelloWorld.class as the Java bytecode must be executed without the extension, .\
is for file execution.