0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

UbuntuでOpenJDK11をインストール

Last updated at Posted at 2020-08-07

OpenJDK11をインストールする

$ sudo apt update
$ sudo apt upgrade -y
$ sudo apt install -y openjdk-11-jdk

環境変数JAVA_HOMEを設定する

$ cat >> ~/.bashrc <<'EOF'
# set JAVA_HOME adn append PATH
JAVA_HOME=$(readlink -f /usr/bin/javac | sed "s:/bin/javac::")
export JAVA_HOME
PATH=$PATH:$JAVA_HOME/bin
export PATH
EOF

bashrc更新

$ source ~/.bashrc

環境変数JAVA_HOMEを確認

$ echo $JAVA_HOME
/usr/lib/jvm/java-11-openjdk-amd64

すでにjava11以外のバージョンをインストールしている人は、デフォルトのバージョンを切り替える

  • javaコマンドのパージョンを切り替える
sudo update-alternatives --config java
  • javacコマンドのバージョンとを切り替える
sudo update-alternatives --config javac
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?