Linux上安装jdk
跳到导航
跳到搜索
针对不同发行版本下载相对应包
evan@myxps:~/data/devops/jdk$ sha1sum jdk-8u212-linux-x64.rpm ca6872ac2f203637322ba2872cbfb3c5889d6c8d jdk-8u212-linux-x64.rpm evan@myxps:~/data/devops/jdk$ cat jdk-8u212-linux-x64.rpm.sha1 ca6872ac2f203637322ba2872cbfb3c5889d6c8d rpm -ivh jdk-8u121-linux-x64.rpm
官方可直接下载了 https://www.oracle.com/java/technologies/downloads/#java21
国内下载地址 https://repo.huaweicloud.com/java/jdk
https://github.com/frekele/oracle-java/releases
最近Oracle发布了最新的Java SE 8u211 / Java SE 8u212,但是下载方式也改变了,原先点击Accept License Agreement同意协议即可下载,现在则多加了一步强制登录,看了下创建用户需要的信息还挺多,瞬间就没兴趣继续了;好在这个世界还是温暖的,已经有人将这些搬运到GitHub。详见:https://github.com/frekele/oracle-java/releases
下载通用二进制包解压安装
#sep 2024 export JAVA_HOME=/home/evan/data/apps/jdk export JRE_HOME=${JAVA_HOME}/jre export CLASSPATH=.:$JAVA_HOME/lib:${JRE_HOME}/lib export PATH=$PATH:$JAVA_HOME/bin:$PATH #像debian 10上没有直接的 jdk8 deb包 那就这样吧 https://repo.huaweicloud.com/java/jdk/8u201-b09/jdk-8u201-linux-x64.tar.gz tar xvf jdk-8u201-linux-x64.tar.gz mkdir -p /data/apps mv jdk1.8.0_201 /data/apps/jdk echo 'JAVA_HOME=/data/apps/jdk/ CLASSPATH=.:$JAVA_HOME/lib.tools.jar PATH=$PATH:$JAVA_HOME/bin export JAVA_HOME PATH' >>/etc/profile source /etc/profile # 如果是rpm包 #set java environment 建议用这个 JAVA_HOME=/usr/java/jdk1.7.0_79 JRE_HOME=/usr/java/jdk1.7.0_79/jre CLASS_PATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin export JAVA_HOME JRE_HOME CLASS_PATH PATH
configure
#set java environment 如果是rpm安装 JAVA_HOME=/usr/java/jdk1.8.0_121 JRE_HOME=/usr/java/jdk1.8.0_121/jre CLASS_PATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin export JAVA_HOME JRE_HOME CLASS_PATH PATH
openjdk configure on kali
How to set JAVA_HOME in Linux for all users http://stackoverflow.com/questions/24641536/ddg#24641640 find /usr/lib/jvm/java-1.x.x-openjdk vim /etc/profile Prepend sudo if logged in as not-privileged user, ie. sudo vim Press 'i' to get in insert mode add: export JAVA_HOME="path that you found" export PATH=$JAVA_HOME/bin:$PATH logout and login again, reboot, or use source /etc/profile to apply changes immediately in your current shell evan@myxps:~$ java --version Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true openjdk 11.0.8 2020-07-14 OpenJDK Runtime Environment (build 11.0.8+10-post-Debian-1) OpenJDK 64-Bit Server VM (build 11.0.8+10-post-Debian-1, mixed mode, sharing) evan@myxps:~$ ls /usr/lib/jvm/java-1. java-1.11.0-openjdk-amd64/ java-1.8.0-openjdk-amd64/ evan@myxps:~$ ls /usr/lib/jvm/java-1. java-1.11.0-openjdk-amd64/ java-1.8.0-openjdk-amd64/ evan@myxps:~$ ls /usr/lib/jvm/java-1.8.0-openjdk-amd64
debian 移除java
jave version which java dpkg --list| grep -i java apt remove --purge <package-name> sudo rm -rf <install directory>
https://blog.51cto.com/u_16175435/9074649
参考
https://docs.oracle.com/cd/E19509-01/820-5483/inst_jdk_javahome_t/
http://wiki.jikexueyuan.com/project/linux-in-eye-of-java/JDK-Install.html