Tag Archives: bash: java: command not found

About javac error bash: Java: command not found solution

preface

I have successfully installed Java and used it without any problem. I haven’t moved it for a long time. Recently, I suddenly wanted to use it, but I found that the javac command reported an error bash: Java: command not found. I searched a lot of information on the Internet and reinstalled it five or six times, but it didn’t solve the problem. I suddenly had an inspiration in the morning, tried it, and then solved it. I hereby record it, I hope I can bring help to my friends who encounter the same problems.

Problem description

Many schemes on the Internet refer to the configuration of environment variables. The author has compared them many times, changed folders in different locations and reinstalled them many times, but he doesn’t think there is a problem with his configuration, CMD — & gt; There is no problem entering Java commands, but javac always reports errors, which is very confused.

Problem solving

Finally, the author found that it was really the problem of environment variable configuration. It was not that the content of the configuration was wrong, but that although he installed it many times, he only changed Java for the configured environment variables for fear of trouble_ The problem has not been solved because of the value of home… Therefore, after uninstalling the Java software, remember to delete the environment variable configuration and reset it when reinstalling to solve the problem.

Attach the configured environment variables:

JAVA_ HOME

E:\ProgramFiles\Java\JDK

CLASSPATH

.;% JAVA_ HOME%\lib\dt.jar;% JAVA_ HOME%\lib\tools.jar;

Path

%JAVA_ HOME%\bin;% JAVA_ HOME%\jre\bin;

PS:

1. JAVA_ The value of the home variable is simply the folder where you install the JDK part of the Java software

2. The values of classpath variable and path variable can be used directly

3. The value of classpath variable should be preceded by a “.”