Skip to content
Advertisement

Unable to get PATH to be set for all users

Trying to get OpenJDK 17 installed for Pufferpanel. User pi can do java -version fine however Pufferpanel gets bash: java: command not found

My /etc/profile and /etc/profile.d/java.sh have these lines:

#JAVA
export JAVA_HOME="/usr/lib/jvm/jdk-17.0.1+12"
export PATH=$JAVA_HOME/bin:$PATH

In addition JAVA_HOME="/usr/lib/jvm/jdk-17.0.1+12" is set in /etc/environment

Full permissions have been given for java.sh and the JAVA_HOME folder with chmod 777. The user pufferpanel now can run the script however the error stays the same: bash: java: command not found.

Trying some things out and found this:

pufferpanel@raspberrypi:/home/pi$ whereis java
java: /usr/share/java

Meanwhile pi gives this output:

pi@raspberrypi:~ $ whereis java
java: /usr/share/java /usr/lib/jvm/jdk-17.0.1+12/bin/java

Good news is that Java does run as the user pufferpanel:

pufferpanel@raspberrypi:/usr/lib/jvm/jdk-17.0.1+12/bin$ ./java -version
openjdk version "17.0.1" 2021-10-19
OpenJDK Runtime Environment Temurin-17.0.1+12 (build 17.0.1+12)
OpenJDK Server VM Temurin-17.0.1+12 (build 17.0.1+12, mixed mode, sharing)

My guess is that PATH is getting overwritten somewhere, just don’t know where.

If there are easier ways to install Java that is higher than version 16 just to get Minecraft to work, please tell me!

Advertisement

Answer

Setting the PATH in ~/.bashrc worked out, copied java.sh and pasted it in. Couldn’t find ~/.bashrc at first, but this helped to figure that out.

As Pufferpanel is a different matter, I’m marking this the answer to my question which was getting Java to work as an user.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement