Afternoon everyone,
I\'m a student studying Computer Science and I\'m trying to recreate the environment my friend is using to host their PHP based web app. They\'re on a
You can do this very simply by adding the environment variable to your .bashrc
file, assuming that your Windows Environment variables are set correctly and WSL is installed, I'm going to use Java as an example, but any environment variable will work.
Use text editor in WSL or type code .bashrc
from WSL home to initialize the WSL VSCode editor. Add the environment variable to the file:
# Shared environment variables
export JAVA_HOME=/mnt/d/Java/jdk11.0.4_10
Just ensure that you change the directory to point to your directory. In my case, it's in D:\Java\jdk11.0.4_10
which in WSL is /mnt/d/Java/jdk11.0.4_10
Also, since you're using Windows binaries, you must specify the file type when running from a WSL bash shell:
Windows:
javac MyClass.java
java MyClass
WSL:
javac.exe MyClass.java
java.exe MyClass
Note that the .exe
file extension is being used, since we're calling the Windows binary. If it was a native Linux distribution of the JDK you could simply use java
command.
This holds true for any Windows binary that is being run through WSL.