java - editing .bashrc does not change JAVA_HOME -


i wanting change java 8 in ubuntu.

i changed java_home in ~/.bashrc , in /etc/environment , sourced it. caused java_home change.

pepperboy@pepperboy-inspiron-3542:~/desktop$ echo $path /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/lib/jvm/jre1.8.0_45/bin:/home/pepperboy/desktop/hadoopinstallation/hadoop-1.2.1/bin pepperboy@pepperboy-inspiron-3542:~/desktop$ echo $java_home /usr/lib/jvm/jre1.8.0_45  pepperboy@pepperboy-inspiron-3542:~/desktop$ cat /etc/environment  path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games" export java_home="/usr/lib/jvm/jre1.8.0_45/bin/" 

however, java version still kept showing earlier version.

pepperboy@pepperboy-inspiron-3542:~/desktop$ java -version java version "1.7.0_75" openjdk runtime environment (icedtea 2.5.4) (7u75-2.5.4-1~precise1) openjdk 64-bit server vm (build 24.75-b04, mixed mode)  also, running below commmand gives me options java 6 , 7, not java 8 pepperboy@pepperboy-inspiron-3542:~/desktop$ sudo update-alternatives --config java there 2 choices alternative java (providing /usr/bin/java).    selection    path                                            priority   status ------------------------------------------------------------   0            /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java   1061      auto mode   1            /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java   1061      manual mode * 2            /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java   1051      manual mode  press enter keep current choice[*], or type selection number:  

finally, running below gave me symlink pointed me actual java executable system using. edited java 8 downloaded, , java -version shows correct version.

pepperboy@pepperboy-inspiron-3542:~/desktop$ java /usr/bin/java pepperboy@pepperboy-inspiron-3542:~/desktop$ ls -l /usr/bin/java lrwxrwxrwx 1 root root 22 apr 29  2014 /usr/bin/java -> /etc/alternatives/java pepperboy@pepperboy-inspiron-3542:~/desktop$ ls -l /etc/alternatives/java lrwxrwxrwx 1 root root 46 oct 17  2014 /etc/alternatives/java -> /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java 

my question :

  1. if edit brings change, why editing ~/.bashrc. looks have run or whereis command in linux, tells me /usr/bin/java actual executable system running, , go , edit point new java version have downloaded

java_home used other tools want invoke java. (usually) java under java_home if it's set. if not use whatever java found on $path. if want use java_home finding java in shell, have add path; there's nothing magical way shell searches binaries, lets special when searching java.

you can use:

export java_home=/usr/lib/jvm/jre1.8.0_45  export path=$java_home/bin:$path 

also, on ubuntu if there multiple different versions or types of given package installable @ same time control alternatives system:

$ sudo update-alternatives --config java there 3 choices alternative java (providing /usr/bin/java).    selection    path                                            priority   status ------------------------------------------------------------ * 0            /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java   1071      auto mode   1            /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java   1061      manual mode   2            /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java   1071      manual mode   3            /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java   1081      manual mode  press enter keep current choice[*], or type selection number: 

Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -