Solve the problem that Linux cannot use system commands such as ls\clear after configuring JDK environment variables**
Error description: After CentOS7 installed jdk1.8 in rpm mode, the java environment was configured, and the following error occurred after restarting.
-bash: fg: no job control
-bash: /usr/java/jdk1.8.0_261-amd64/jre/bin: Is a directory
problem causes
Error in jdk configuration information in /etc/profile file
Solution
1. Installing jdk in rpm mode does not need to configure environment variables, delete the jdk configuration information in the /etc/profile file
使用source /etc/profile 命令使修改后的配置文件生效
2. If you need to configure environment variables, you need three steps
- Use the following command to execute the command that was previously inoperable
exportPATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
- Change the configuration file to the following
JAVA_HOME=/usr/java/jdk1.8.0_221-amd64
JRE_HOME=$JAVA_HOME/jre
CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib
PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH
export JAVA_HOME JRE_HOME CLASSPATH PATH
使用命令 source /etc/profile使配置文件生效
Reference article
Link: https://blog.csdn.net/moonmoonroc/article/details/106590642 .