linux中java环境变量不生效,source /etc/profile也不生效
1、即使操作了source /etc/profile也不生效[root@servera ~]# find / -name java/etc/pki/ca-trust/extracted/java/etc/pki/java/etc/java/etc/alternatives/java/var/lib/alternatives/java/usr/bin/java/usr/lib/java/usr/li
·
1、即使操作了source /etc/profile也不生效
[root@servera ~]# find / -name java
/etc/pki/ca-trust/extracted/java
/etc/pki/java
/etc/java
/etc/alternatives/java
/var/lib/alternatives/java
/usr/bin/java
/usr/lib/java
/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.282.b08-1.el7_9.x86_64/jre/bin/java
/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.282.b08-1.el7_9.x86_64/bin/java
/usr/lib/jvm/java
/usr/lib/jvm-exports/java
/usr/share/java
/usr/local/jdk1.8.0_144/bin/java
/usr/local/jdk1.8.0_144/jre/bin/java
/home/software/jdk1.8.0_144/bin/java
/home/software/jdk1.8.0_144/jre/bin/java
[root@servera ~]# rm -rf /usr/bin/java
[root@servera ~]# rm -rf /usr/bin/java
[root@servera ~]# rm -rf /usr/bin/java
[root@servera ~]# java -version
-bash: /usr/bin/java: No such file or directory
[root@servera ~]# vim /etc/profile
[root@servera ~]# source /etc/profile
[root@servera ~]# java
java javac javadoc javafxpackager javah javap javapackager java-rmi.cgi javaws
[root@servera ~]# java -vsersion
Unrecognized option: -vsersion
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
[root@servera ~]# java -version
java version "1.8.0_144"
Java(TM) SE Runtime Environment (build 1.8.0_144-b01)
Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode)
[root@servera ~]# source /etc/profile
[root@servera ~]# java -V
Unrecognized option: -V
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
[root@servera ~]# java -version
java version "1.8.0_144"
Java(TM) SE Runtime Environment (build 1.8.0_144-b01)
Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode)
[root@servera ~]#
2、原因 /usr/bin
因为/usr/bin目录中可执行文件导致配置的环境变量不生效,删除即可
3、配置环境变量配置
export JAVA_HOME=/usr/local/jdk1.8.0_144
export CLASS_PATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/jre/lib/rt.jar
export PATH=$PATH:$JAVA_HOME/bin
更多推荐
已为社区贡献3条内容
所有评论(0)