Adding Java home not working on windows ZSH

I have java installed and set up properly and works fine with the normal Windows Powershell. However, I’m trying to make java work with the ZSH terminal and I cannot get it to work.

My JAVA_HOME (in powershell) is set to this path:

C:\Program Files\Java\jdk-15.0.2

Im trying to add this line to my .zshrc file:

export JAVA_HOME=`/mnt/c/"Program Files"/Java/jdk-15.0.2`

but when i do source .zshrc it says permission denied to that file. Running sudo chmod doesnt seem to help either. Am i doing something wrong or missing some other line to add? Most tutorials for ZSH is on a Mac OS so i dont know if it differs being that im in windows…

>Solution :

The backticks are trying to "execute" that folder as a shell command.

Double quotes will store that variables as a string

export JAVA_HOME="/mnt/c/Program Files/Java/jdk-15.0.2"

But this doesn’t guarantee that java command itself will work.

Leave a Reply