Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

1.5K
Views
What is the proper way of using JDK on WSL2 on Windows 10?

I have installed Ubuntu 20.4 LTS on WSL. My windows 10 already have the JDK installed. Do I need to install JDK on ubuntu on WSL or can I use the Windows 10 JDK in the Ubuntu? How you do Java programming on WSL? Which is the proper way?

I was just wondering if I need to install all the development tools and binaries again on Linux won't it take a lot of space & hog a lot of CPU/Ram resources?

over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

There is not a "proper" (as in supported or recommended by JDK providers) way to install or use Java on WSL. I could not find any official recommendations.

However, it is possible to either install and use Oracle JDK for Windows installation from WSL, or install OpenJDK Java into your WSL world from the Ubuntu package manager.

I was just wondering if I need to install all the development tools and binaries again on Linux won't it take a lot of space & hog a lot of CPU/Ram resources ?

See above. But note that you are only going to "hog CPU/RAM" if you are running both kinds of JVM at the same time.

References:

  • Installing Oracle JDK on Windows subsystem for Linux
  • Java JDK 11 install script for Windows Subsystem for Linux (WSL)
  • Windows Subsystem for Linux Java Setup ... using the Ubuntu package system.

(There are many more articles on this topic if the above don't address your concerns.)

over 4 years ago · Santiago Trujillo Report

0

We can use that Windows JDK inside the wsl2. we should add this to /etc/environment

JAVA_HOME=/mnt/c/Program Files/Java/jdk-11.0.8/bin/

by adding this bin folder we may run regular commands but append with .exe format eg: javac.exe hello.java java.exe hello.java

if you don't like that way then add alias like below:

alias java='java.exe'
alias javac='javac.exe'

I think we can use any of the windows programs like this :)

over 4 years ago · Santiago Trujillo Report

0

Run the following commands as a user with sudo privileges or root to update the packages index and install the OpenJDK 11 JDK package:

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

Once the installation is complete, you can verify it by checking the Java version:

$ java -version

The output should look something like this:

openjdk version "11.0.7" 2020-04-14
OpenJDK Runtime Environment (build 11.0.7+10-post-Ubuntu-3ubuntu1)
OpenJDK 64-Bit Server VM (build 11.0.7+10-post-Ubuntu-3ubuntu1, mixed mode, sharing)

Set JAVA_HOME Environment Variable: OpenJDK 11 is located at /usr/lib/jvm/java-11-openjdk-amd64/bin/java

Once you found the path of your preferred Java installation, open the /etc/environment file:

$ sudo nano /etc/environment

Assuming you want to set JAVA_HOME to point to OpenJDK 11, add the following line, at the end of the file:

JAVA_HOME="/usr/lib/jvm/java-11-openjdk-amd64"

For changes to take effect on your current shell you can either log out and log in or run the following source command:

$ source /etc/environment

Verify that the JAVA_HOME environment variable was correctly set:

$ echo $JAVA_HOME

You should see the path to the Java installation:

/usr/lib/jvm/java-11-openjdk-amd64

for reference you can follow this link below How to Install Java on Ubuntu 20.04

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!