First, check whether Java is successfully installed
java -version
If the version information is displayed, the installation is successful. Just install the corresponding package
yum install java-1.8.0-openjdk-devel.x86_64
First, check whether Java is successfully installed
java -version
If the version information is displayed, the installation is successful. Just install the corresponding package
yum install java-1.8.0-openjdk-devel.x86_64
Problem: javac reports error wakeonlan. Java: 19: error: unmapped character encoding GBK
Reason: the default code of windows is GBK, while the code of java file is UTF-8
resolvent:
Open the java file with UltraEdit and check the code displayed on the status bar in the lower right corner. Here, confirm that it is UTF-8. Or copy the java file into eclipse, right-click and select properties to view its encoding
If you confirm that the file code is UTF-8, add the coding parameter during javac compilation:
javac -encoding UTF-8 WakeOnLan.java
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 “.”
bash: javac: command not found
java version 1.8
[root@localhost home]# java -version
openjdk version "1.8.0_232"
Directly during installation
yum install java
After installation, run javac and report an error. It is found that there are fewer packages, so install the corresponding package again
yum install java-1.8.0-openjdk-devel.x86_64