1. 程式人生 > >ubuntu命令安裝jdk

ubuntu命令安裝jdk

ubuntu命令 5.1 ash plugin JD 配置 進行 inux ase

1.ubuntu使用的是openjdk,所以我們需要先找到合適的jdk版本。在命令行中輸入命令:

$apt-cache search openjdk
  • 1

返回結果列表(因個人電腦而有所不同):

default-jdk-doc - Standard Java or Java compatible Development Kit (documentation)
…(省略部分顯示結果)
openjdk-6-source - OpenJDK Development Kit (JDK) source files
openjdk-7-jre-dcevm - Alternative VM for OpenJDK 7 with enhanced class redefinition
openjdk-7-jre-lib - OpenJDK Java runtime (architecture independent libraries)
openjdk-7-jre-zero - Alternative JVM for OpenJDK, using Zero/Shark
openjdk-8-dbg - Java runtime based on OpenJDK (debugging symbols)
openjdk-8-demo - Java runtime based on OpenJDK (demos and examples)
openjdk-8-doc - OpenJDK Development Kit (JDK) documentation
openjdk-8-jdk - OpenJDK Development Kit (JDK)
openjdk-8-jre - OpenJDK Java runtime, using Hotspot JIT
openjdk-8-jre-headless - OpenJDK Java runtime, using Hotspot JIT (headless)
openjdk-8-jre-jamvm - Alternative JVM for OpenJDK, using JamVM
openjdk-8-jre-zero - Alternative JVM for OpenJDK, using Zero/Shark
openjdk-8-source - OpenJDK Development Kit (JDK) source files
uwsgi-app-integration-plugins - plugins for integration of uWSGI and application
uwsgi-plugin-jvm-openjdk-7 - Java plugin for uWSGI (OpenJDK 7)

2.從搜索的列表裏找到我們需要安裝的jdk版本,如上面標黑的
openjdk-8-jdk - OpenJDK Development Kit (JDK)

3.輸入安裝命令,進行安裝:

$sudo apt-get install openjdk-8-jdk
  • 1

等待命令行顯示“done”,即安裝成功過。

4.查看安裝結果。輸入命令:

$java -version
  • 1

顯示結果如下:
openjdk version “1.8.0_91”
OpenJDK Runtime Environment (build 1.8.0_91-8u91-b14-0ubuntu4~15.10.1-b14)
OpenJDK Server VM (build 25.91-b14, mixed mode)
則說明安裝成功。

5.安裝成功後,還需要配置java_home變量:

1)輸入命令:echo $java_home
返回空行;

2)which javac
返回:/usr/bin/javac

3)file /usr/bin/javac
返回:/usr/bin/javac: symbolic link to /etc/alternatives/javac

4)file /etc/alternatives/javac
返回:/etc/alternatives/javac: symbolic link to /usr/lib/jvm/java-8-openjdk-i386/bin/javac

5)file /usr/lib/jvm/java-8-openjdk-i386/bin/javac
返回:/usr/lib/jvm/java-8-openjdk-i386/bin/javac: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=a8eeb948df0418fc8f046910c73713f2b6697a9a, stripped

6)sudo echo export JAVA_HOME=”/usr/lib/jvm/java-8-openjdk-i386/bin”>>~/.bashrc
輸入密碼;

7)source ~/.bashrc

8)測試命令:gedit ~/.bashrc
查看打開的文件末尾是否成功加入java_home

ubuntu命令安裝jdk