When compiling the code via the command line, using the javac command, the following error is issued
The path to bin is registered. Everything seems to be correct, but it still gives an error. What could be the matter?
Answer 1, authority 100%
Cause of error – Incorrect “environment variables” were set. Accordingly, you must specify the correct ones.
On your desktop, open This PC:
- Click on the top left “Properties”, then on the left in the menu –
Advanced System Settings. - In the “Advanced” tab that opens, at the very bottom, select
Environment Variables. - Content will open. Click “Create” in each window one by one.
- In the New User Variable window, write CLASSPATH.
- Then, in the New System Variable window, specify the PATH variable. V
in the “Value” field, specify the directory for the JDK package. - Restart Windows.
Alternatively, to run Javac, you can specify the full path to the console on the command line. For example: C: \ Program Files \ Java \ jdk1.8.0_102 \ bin \ javac.exe "MyFile.java
Answer 2, authority 14%
If it didn’t help, adding to the CLASSPATH, then add the same path to the PATH, if there is already something there, add a semicolon ‘;’
Answer 3
If nothing has changed after adding the paths, then make copies of the jdk folders in Programm Files / java and Programm Files (x86) / java
Answer 4
A small addition, we write the path in variables to the bin folder, otherwise it will not work. Example:
C: \ Program Files \ Java \ jdk1.8.0_201 \ bin
You probably won’t need to reboot, but be sure to restart the command line.
Answer 5
It is necessary to move JAVA_HOME
to the very beginning of the PATH
variable so that it is before the standard path that was registered during installation:
C: \ Program Files (x86) \ Common Files \ Oracle \ Java \ javapath