I installed openjdk with sudo snap install openjdk
, and
I want to set JAVA_HOME
to enable my java
related commands in terminal, but it is not working.
I tried the following:
- creating a script
java_home.sh
in/etc/profile.d
with the contentJAVA_HOME=/snap/openjdk/current/jdk
and doing logout/login, but it is not working - creating a script
java_home.sh
in/etc/profile.d
with the contentsource $(openjdk)
and doing logout/login, but it is not working - adding
JAVA_HOME=/snap/openjdk/current/jdk export PATH=$PATH:$JAVA_HOME
to~/.bashrc
, and opening new terminal, but it is still not working
I don't know what to try, or what to do, so if anyone can help, I will be very thankful.
The output of ls /snap/openjdk
is 909 current
.
The output of cat $(openjdk)
is:
# Source this file for OpenJDK environment variables and aliases
export JAVA_HOME=/snap/openjdk/909/jdk
export MANPATH=/snap/openjdk/909/jdk/man:
alias java='openjdk.java'
alias javac='openjdk.javac'
alias javadoc='openjdk.javadoc'
alias jar='openjdk.jar'
alias jarsigner='openjdk.jarsigner'
alias jlink='openjdk.jlink'
alias jpackage='openjdk.jpackage'
alias jwebserver='openjdk.jwebserver'
when doing source openjdk
, it starts working, but I don't want to do that every time and want it loaded everywhere as a env variable.