Install Java on WSL Ubuntu 18.04

environment

-Host OS: Windows10 Home · Virtual OS: WSL Ubuntu18.04 lts (Ubuntu 18.04 is installed using wsl installed in windows 10)

Overview

-Install Java on ubuntu 18.04.

procedure

① Package update

$ sudo apt update

② Install OPEN JRE

$ sudo apt-get install default-jre

Check if JRE is installed with the following command

$ java --version
openjdk 11.0.6 2020-01-14
OpenJDK Runtime Environment (build 11.0.6+10-post-Ubuntu-1ubuntu118.04.1)
OpenJDK 64-Bit Server VM (build 11.0.6+10-post-Ubuntu-1ubuntu118.04.1, mixed mode, sharing)

② Install OPEN JDK

$ sudo apt-get install default-jdk

Make sure you have the same installation as before. javac is a command that deals with the Java compiler.

$ javac --version
javac 11.0.6

Both ① and ② can be installed by specifying the version, but I think it is safe to install the latest version with default-jre and default-jdk until you are used to it.

③ Setting environment variables

First, check the java installation path with the following command.

$ sudo update-alternatives --config java
There is only one alternative in link group java (providing /usr/bin/java): /usr/lib/jvm/java-11-openjdk-amd64/bin/java
Nothing to configure

I was able to confirm that the Java installation path is / usr / lib / jvm / java-11-openjdk-amd64.

Then open the bash file with the following command.

$ vi ~/.bashrc

Set the following environment variables in the bash file.

export JDK_HOME = "/usr/lib/jvm/java-11-openjdk-amd64"

export PATH="$JDK_HOME:$PATH"

After saving your edits with the: wq! Command, close the bash file.

** * When I read the article about Java environment construction, I often set the environment variable to $ JAVA_HOME, but then the VScode extension did not work and I felt it was inconvenient. ** **

Make sure the environment variables are set.

$ echo $JDK_HOME
/usr/lib/jvm/java-1.11.0-openjdk-amd64

You have successfully installed Java.

Recommended Posts

Install Java on WSL Ubuntu 18.04
Install Java on Mac
Install pyqt5 on ubuntu
Install Autoware on Ubuntu 18.04.5
ubuntu on wsl part 10
Install Homebrew on Ubuntu 20.04
Install Docker on Ubuntu Server 20.04
Oracle Java 8 on Docker Ubuntu
Install zabbix agent (5.0) on Ubuntu 18.04
Install Arudino IDE on Ubuntu 20
Ruby installation on WSL2 + Ubuntu 20.04
Install Ubuntu Desktop 20.10 on RaspberryPi4
Install Arduino IDE on Ubuntu 20.04
Run java applet on ubuntu
Install raspi-config on Ubuntu 20.04 (LTS)
Install WordPress 5.5 on Ubuntu 20.04 LTS
Install PlantUML on Intellij on Ubuntu
Install Ubuntu Server 20.04 on Btrfs
Note: Install PostgreSQL 9.5 on Ubuntu 18.04
Install java 1.8.0 on Amazon linux2
Install java with Ubuntu 16.04 based Docker
Install AWS IoT Greengrass on Ubuntu
Install JDK and JRE on Ubuntu 16.10
Install ngrok on ubuntu16.04 using Vagrant
Install Java Open JDK 8 on CentOS 7
How to install WildFly on Ubuntu 18.04
Install MQTT broker Mosquitto on Ubuntu 18.04
Enable Java 8 and Java 11 SDKs on Ubuntu
Install SonarQube on ECS instance on Ubuntu 16.04
Elmer / Ice installation (Ubuntu on WSL)
Java cannot be installed on Ubuntu 13.04
Install ruby on Ubuntu 20.04 with rbenv
Install Java 9 on windows 10 and CentOS 7
Install Java development environment on Mac
How to install java9 on elementaryOS Freya or Ubuntu 14.04 LTS
If you can't install java on Catalina
WSL2 + Ubuntu 20.04 Install Vivado in LTS environment
Using JupyterLab + Java with WSL on Windows 10
How to install production Metabase on Ubuntu
I want to install PHP 7.2 on Ubuntu 20.04.
Install Realtek network driver on Ubuntu Note
Install Java8 with Yum on Amazon Linux
Use cljstyle with Spacemacs on Ubuntu on WSL2
Build OpenCV with Java Wrapper on Ubuntu 18.04
Try putting Docker in ubuntu on WSL
tmux on Ubuntu
Try running ScalarDB on WSL Ubuntu (Environment Construction)
Install java and android-sdk on Mac using homebrew
Build and install Wireshark Development Release (3.3.1) on Ubuntu
Install Ubuntu Core 18 on Raspberry Pi 2 Model B
How to install network drivers on standalone Ubuntu
Install Java 11 (OpenJDK: AdoptOpenJDK) on macOS with Homebrew
[Java] Build Java development environment on Ubuntu & check execution
How to install NVIDIA driver on Ubuntu 18.04 (Note)
Install Java 14 (OpenJDK: AdoptOpenJDK) on macOS with Homebrew
Set up an SSH server on WSL2 Ubuntu 20.04
Install Java 8 (OpenJDK: AdoptOpenJDK) on macOS with Homebrew
How to install multiple JDKs on Ubuntu 18.04 LTS
Install and switch between multiple Javas on Ubuntu
Docker on Ubuntu18.04 on WSL2 and VSCode installation instructions
Install Java, Apache, Tomcat9 on EC2 (Amazon Linux2)