问题描述
jps 显示 command not found …
[root@localhost software]# jps
bash: jps: command not found...
[root@localhost software]# javac
bash: javac: command not found...
Similar command is: 'java'
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
如果有上面的现象表示java环境变量没有安装好,需要安装jdk(8)
step1
copy jdk 到目录 /opt/software 下面
step2 新建目录 /usr/local/java
[root@localhost software]# cd /usr/local/java
[root@localhost java]# pwd
/usr/local/java
- 1
- 2
- 3
step3 将 jdk 解压到目录/usr/local/java/下面
[root@localhost software]# pwd
/opt/software
[root@localhost software]# tar -zxvf -C /usr/local/java/
[root@localhost jdk1.8.0_251]# pwd
/usr/local/java/jdk1.8.0_251
[root@localhost jdk1.8.0_251]# ll
total 25836
drwxr-xr-x. 2 10143 10143 4096 Mar 11 2020 bin
-r--r--r--. 1 10143 10143 3244 Mar 11 2020 COPYRIGHT
drwxr-xr-x. 3 10143 10143 132 Mar 11 2020 include
-rw-r--r--. 1 10143 10143 5217764 Mar 11 2020
drwxr-xr-x. 5 10143 10143 185 Mar 11 2020 jre
drwxr-xr-x. 5 10143 10143 245 Mar 11 2020 lib
-r--r--r--. 1 10143 10143 44 Mar 11 2020 LICENSE
drwxr-xr-x. 4 10143 10143 47 Mar 11 2020 man
-r--r--r--. 1 10143 10143 159 Mar 11 2020
-rw-r--r--. 1 10143 10143 424 Mar 11 2020 release
-rw-r--r--. 1 10143 10143 20923007 Mar 11 2020
-rw-r--r--. 1 10143 10143 117365 Mar 11 2020
-r--r--r--. 1 10143 10143 169571 Mar 11 2020
[root@localhost jdk1.8.0_251]# pwd
/usr/local/java/jdk1.8.0_251
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
step4 编辑profile 文件 并重新加载
vim /etc/profile
export JAVA_HOME=/usr/local/java/jdk1.8.0_251
export JRE_HOME=/usr/local/java/jdk1.8.0_251/jre
export CLASSPATH=.:$CLASSPATH:$JAVA_HOME/lib:$JRE_HOME/lib
export PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
- 1
- 2
- 3
- 4
[root@localhost jdk1.8.0_251]# source /etc/profile
step5 验证是否可以
[root@localhost jdk1.8.0_251]# jps
47087 Jps
[root@localhost jdk1.8.0_251]# javac
....
- 1
- 2
- 3
- 4
- 5