I'm trying to get WSL to recognize my windows installed environmental variable of JAVA_HOME. I attached of what I have in my bashrc and what I have in my windows environmental variables along with outputs from cmd and bash.
What's at the end of my bashrc:
export JAVA_HOME="/mnt/d/Program Files/Java/jdk-11.0.1"
export PATH="/mnt/d/Program Files/Java/jdk-11.0.1/bin:$PATH"
CMD INPUT/OUTPUT:
C:\Users\jaall>javac --version
javac 11.0.1
BASH INPUT/OUTPUT:
myubuntu_name@DESKTOP-LUK3BII:~$ javac --version
Command 'javac' not found, but can be installed with:
sudo apt install default-jdk
sudo apt install openjdk-11-jdk-headless
sudo apt install ecj
sudo apt install openjdk-8-jdk-headless
I've been stuck on this for awhile and can't figure it out or find a working solution online. Thanks!
As Biswapriyo suggested, you should use WSLENV.
Open PowerShell. Then set JAVA_HOME to the path to your java installation.
In your case, run setx JAVA_HOME "D:\Program Files\Java\jdk-11.0.1"
You should see a message that says "SUCCESS: Specified value was saved.
setx WSLENV "JAVA_HOME/p"
You should see the success message again.
You should see JAVA_HOME correctly set at this point.
Note: If step 2 doesn't work, you might want to changing the path to JAVA_HOME to include the '\bin' folder.