Ubuntu – In which system file does ‘export’ command make changes

bashcommand lineenvironment-variablesfilesystemjava

I installed java-8 using a PPA. After that I gave a command:

export JAVA_HOME=/usr/lib/jvm/java-8-oracle

I had heard somewhere that this command does temporary changes. But after many logouts and logins, these commands below still works (I think due to that export ... command):

java -version
javac -version

But when I give the command:

export -p

It shows a list of environment variables, but in that list, does not show variable JAVA_HOME. Moreover, I wonder how the commands java and javac still works!

Can someone tell me in which file export command make changes? Are they temporary or permanent? And what else happens above? Please elaborate!

Best Answer

export is a shell command. It affects the current running instance of the shell. It does not make changes in any file. The changes are temporary, only in effect until the shell exits. Once you set a new variable in the shell, to make it available to other programs started from it, you export it. See:

java and javac might work because you installed Java using a PPA, and the installation automatically added these commands to the PATH (What is the PATH environment variable and how do I add to it?). Specifically, just checking the version shouldn't need the JAVA_HOME variable. Whether you set it or not makes no difference just for that. And apparently JAVA_HOME is used by other applications, not the Java compiler or the JVM.