My college currently uses a very old (like 3 years old) openJDK 1.7 distribution. And being a student, obviously I don't have root privileges. I wanted to use a much later version downloaded a much more recent version from their official website since one of my app (solr) requires it.

I downloaded the JRE 1.8 and checked the interpreter using

saikrishnac@chervil:~/jre18/bin$ ./java -version
java version "1.8.0_101"
Java(TM) SE Runtime Environment (build 1.8.0_101-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.101-b13, mixed mode)

It turned out to be just as expected. Now I want to direct all the java calls made by the app to this bin. But, by default, this is what the university has running

saikrishnac@chervil:~$ java -version
java version "1.7.0_91"
OpenJDK Runtime Environment (IcedTea 2.6.3) (7u91-2.6.3-1~deb8u1)
OpenJDK 64-Bit Server VM (build 24.91-b01, mixed mode)

So, I'm guessing I need to change the JAVA_PATH variable in /etc/profie. But I've only read only access and hence I cannot add the following.

export JAVA_HOME="path"
export PATH=$JAVA_HOME/bin:$PATH

The above was suggested at: https://stackoverflow.com/questions/24641536/how-to-set-java-home-in-linux-for-all-users


So, is there any workaround for changing the path for just my user account. I mean, when i run java in my account I wish it executed with the jre18 binary.


The guide that you presented tells you how to set these variables globally - for all users. Since you only want to set these for yourself, you should put them in ~/.bashrc EDIT: As Gilles pointed out in the comment below, .bashrc is intended for interactive settings, and few things can go wrong under some circumstances. Instead, you should put them in .profile.

| improve this answer | |
  • Yes, thank you. I answered my own question for someone with the same question :) – Sai krishna Deep Jul 20 '16 at 13:48
  • No, not .bashrc. .profile is the place for environment variables, .bashrc is for interactive settings. Among the things that can go wrong, .bashrc doesn't apply to programs started through a GUI, and overrides changed settings in a sub-session. – Gilles 'SO- stop being evil' Jul 20 '16 at 21:35

Not the answer you're looking for? Browse other questions tagged or ask your own question.