• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Setting JAVA_HOME and override the default

 
Joe Harry
Ranch Hand
Posts: 10124
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wanted to set the JAVA_HOME globally, so I edited the /etc/profile and added the following:



But when I do which java, it still points to /usr/bin/java. How to override that and ask my Raspberry to use the Java version that I want? Should I reboot? I did a source /etc/profile. Isn't that enough?
 
Campbell Ritchie
Sheriff
Pie
Posts: 49813
69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should add your new Java installation to the beginning of the PATH.
It should work whenever you open a new terminal.
 
Joe Harry
Ranch Hand
Posts: 10124
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:You should add your new Java installation to the beginning of the PATH.
It should work whenever you open a new terminal.


I did the following and I do not see the /usr/bin/java in the PATH. From where is it pulling it?



Yes, I did add it to the beginning of the path and that did the trick!
 
Campbell Ritchie
Sheriff
Pie
Posts: 49813
69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is a similar file somewhere else; I can't remember where. Probably in /etc. I have looked and can't find it on my machine.
 
Campbell Ritchie
Sheriff
Pie
Posts: 49813
69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Joe Harry wrote: . . .
pi@Menne ~ $ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games:/opt/softwares/jdk1.7.0_45/bin
When you use which, it finds a “java” in /usr/bin, so that is /usr/bin/java. The which app reports whichever it finds first, and then stops looking. The default java installation is usually in /usr/bin.
Yes, I did add it to the beginning of the path and that did the trick!
Success!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic