1
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?

UbuntuにJava実行環境を用意する

Last updated at Posted at 2025-03-08

はじめに

Springで作成したWebアプリケーションのJarファイルを実行する環境が欲しかったのでWSLのUbuntuに環境を用意してみます。

JDKをインストールする

適宜、求めるバージョンを選択してください。

$ sudo add-apt-repository ppa:webupd8team/java
$ java -v
Command 'java' not found, but can be installed with:
sudo apt install openjdk-17-jre-headless  # version 17.0.12+7-1ubuntu2~24.04, or
sudo apt install openjdk-21-jre-headless  # version 21.0.4+7-1ubuntu2~24.04
sudo apt install default-jre              # version 2:1.17-75
sudo apt install openjdk-19-jre-headless  # version 19.0.2+7-4
sudo apt install openjdk-20-jre-headless  # version 20.0.2+9-1
sudo apt install openjdk-22-jre-headless  # version 22~22ea-1
sudo apt install openjdk-11-jre-headless  # version 11.0.24+8-1ubuntu3~24.04.1
sudo apt install openjdk-8-jre-headless   # version 8u422-b05-1~24.04
$ sudo apt install openjdk-21-jre-headless

JAVA_HOMEの設定

// export JAVA_HOME=/usr/lib/jvm/<インストールしたjdk>
export JAVA_HOME=/usr/lib/jvm/java-1.21.0-openjdk-amd64
export PATH="$PATH:$JAVA_HOME/bin"

おわり

完了です。Jarを実行しましょう

$ java -jar <jarファイル名>
1
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
1
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?