Setting persistent environment variable in CentOS 7 issue

If it is about setting JAVA_HOME system-wide, /etc/profile.d/ would be a good choice.

echo export JAVA_HOME="put path to java home here">/etc/profile.d/javaenv.sh
chmod 0755 /etc/profile.d/javaenv.sh

on your next logon you'll have it


Depending on your shell, there usually has to be a .<shellnamehere>rc file where you can store these variables that you want persisting across logout and reboot events. .bashrc is where you do it if your shell choice is bash

EDIT: in the terminal, run command

env | grep SHELL

if you see SHELL=bash then, run this command:

echo 'export JAVA_HOME="/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.71-2.b15.el7_2.x86_64"' >> $HOME/.bashrc

this last command have some assumptions. If your SHELL doesn't come up as bash come back here and report what you get. After a logout and login back if you don't see your variable already set, again come back and report what error messages you see, if any.