I installed a JDK in /opt, and placed a shell script in /etc/profile.d/ where I used export to modify the PATH variable so I could run Java nicely. Thing is, this only worked for my local account, not sudo. If I try to sudo the command, it says sudo: java: command not found. I've tried putting the export commands at the end of .bashrc and rc.local, but neither option seems to change this behavior. I want to be able to run sudo java, so where can I modify the PATH at bootup time in such a way that sudo sees it?
Edit: For the record, these are the lines I've added in every place I've attempted:
export JAVA_HOME="/opt/jdk-16.0.2"
export PATH="$PATH:${JAVA_HOME}/bin"
/etc/profile. :) – Señor CMasMas Jun 23 '22 at 21:38javais recognized, notsudo javaagain – HydroPage Jun 23 '22 at 21:48sudo -E? – test1696150 Jun 24 '22 at 03:32