SUSE 12 JDK安装

SUSE 12 JDK安装


# 查看SUSE 版本,12.3
suse12:~ # cat /etc/SuSE-release 
SUSE Linux Enterprise Server 12 (x86_64)
VERSION = 12
PATCHLEVEL = 3
# This file is deprecated and will be removed in a future service pack or release.
# Please check /etc/os-release for details about this release.

# 查看cpu位数,64
suse12:~ # uname -a
Linux suse12 4.4.73-5-default #1 SMP Tue Jul 4 15:33:39 UTC 2017 (b7ce4e4) x86_64 x86_64 x86_64 GNU/Linux

# FTP上传Jdk压缩包,解压
suse12:~ # tar -xzf jdk-8u152-linux-x64.tar.gz
suse12:~ # ll|grep jdk
-rwxrwxr-x 1 root root 189784266 May 18 18:44 jdk-8u152-linux-x64.tar.gz
drwxrwxr-x 1 root root       274 Sep 14  2017 jdk1.8.0_152

# 查看PAT系统变量
suse12:~ # echo $PATH
/sbin:/usr/sbin:/usr/local/sbin:/root/bin:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games:/usr/sbin/java/bin
# 确认下要放得目录下没有java目录
suse12:~ # ll /usr/sbin/|grep java
# 移动并改名为java
suse12:~ # mv jdk1.8.0_152/ /usr/local/java 
suse12:~ # ll /usr/sbin/|grep java 
drwxr-xr-x 1 root root         274 May 18 18:45 java

SUSE 12 Java 环境验证1


# 这里查看下java版本会报下错,需要绝对路径
suse12:~ # java  -version
Absolute path to 'java' is '/usr/sbin/java', so running it may require superuser privileges (eg. root).

suse12:~ # /usr/sbin/java/jre/bin/java  -version
java version "1.8.0_152"
Java(TM) SE Runtime Environment (build 1.8.0_152-b16)
Java HotSpot(TM) 64-Bit Server VM (build 25.152-b16, mixed mode)

SUSE 12 Java 环境验证2

# 将jdk信息添加至环境变量
suse12:~ # vi /etc/profile
# 文末添加
export JAVA_HOME=/usr/sbin/java
CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$PATH:$JAVA_HOME/bin

# 刷新环境变量
suse12:~ # source /etc/profile

# 检查下效果
suse12:~ # jps 
7659 Jps

suse12:~ # java -version 
java version "1.8.0_152"
Java(TM) SE Runtime Environment (build 1.8.0_152-b16)
Java HotSpot(TM) 64-Bit Server VM (build 25.152-b16, mixed mode)

suse12:~ # echo $JAVA_HOME
/usr/sbin/java

SUSE 12 Java 环境验证3


# 创建一个测试用户
suse12:~ # groupadd -g 100 app 
suse12:~ # useradd -d /home/app -s /bin/bash -u 100 -g app app
suse12:~ # id app
uid=100(app) gid=100(users) groups=100(users)
suse12:~ # clear 
suse12:~ # su - app

# 发现java环境变量已经完全生效了,普通用户就能用jdk了
app@suse12:~> java -version
java version "1.8.0_152"
Java(TM) SE Runtime Environment (build 1.8.0_152-b16)
Java HotSpot(TM) 64-Bit Server VM (build 25.152-b16, mixed mode)

app@suse12:~> jps 
7449 Jps
app@suse12:~> echo $JAVA_HOME 
/usr/sbin/java

你可能感兴趣的:(排错,运维,web)