• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 592
  • Last Modified:

setting path variable

when i run java version, i get jdk version of the one that is came along with OS, i installed new jdk as below and set the path in .bashrc and sourced by still when i run java -version i get system jdk, how to override system jdk path setting by by user account


[webadmin@centos5 software]$ cd /app/govi/jdk1.6.0_29/bin
[webadmin@centos5 bin]$ pwd
/app/govi/jdk1.6.0_29/bin
[webadmin@centos5 bin]$ cat ~/.bashrc
# .bashrc

# Source global definitions
if [ -f /etc/bashrc ]; then
        . /etc/bashrc
fi
alias l='ls -ltr'

# User specific aliases and functions
# The following are the environment variables for Java, ANT and JBoss

export JAVA_HOME=/app/govi/jdk1.6.0_29
export PATH=$PATH:$JAVA_HOME/bin

export ANT_HOME=/app/govi/ant-1.8.2
export PATH=$PATH:$ANT_HOME/bin

export JBOSS_HOME=/app/govi/jboss-5.1.0.GA
export PATH=$PATH:$JBOSS_HOME/bin

#export CLASSPATH=$CLASSPATH:/opt/software/junit-4.10.jar:/app/govi/ant-1.8.2_src/build/lib/ant-junit4.jar

# User specific aliases and functions
[webadmin@centos5 bin]$ pwd
/app/govi/jdk1.6.0_29/bin
[webadmin@centos5 bin]$ java -version
java version "1.6.0_20"
OpenJDK Runtime Environment (IcedTea6 1.9.8) (rhel-1.22.1.9.8.el5_6-i386)
OpenJDK Client VM (build 19.0-b09, mixed mode)
[webadmin@centos5 bin]$ cat ~/.bashrc
# .bashrc

# Source global definitions
if [ -f /etc/bashrc ]; then
        . /etc/bashrc
fi
alias l='ls -ltr'

# User specific aliases and functions
# The following are the environment variables for Java, ANT and JBoss

export JAVA_HOME=/app/govi/jdk1.6.0_29
export PATH=$PATH:$JAVA_HOME/bin

export ANT_HOME=/app/govi/ant-1.8.2
export PATH=$PATH:$ANT_HOME/bin

export JBOSS_HOME=/app/govi/jboss-5.1.0.GA
export PATH=$PATH:$JBOSS_HOME/bin

#export CLASSPATH=$CLASSPATH:/opt/software/junit-4.10.jar:/app/govi/ant-1.8.2_src/build/lib/ant-junit4.jar

# User specific aliases and functions
[webadmin@centos5 bin]$ source ~/.bashrc
[webadmin@centos5 bin]$ pwd
/app/govi/jdk1.6.0_29/bin
[webadmin@centos5 bin]$ ./java -version
java version "1.6.0_29"
Java(TM) SE Runtime Environment (build 1.6.0_29-b11)
Java HotSpot(TM) Client VM (build 20.4-b02, mixed mode, sharing)
[webadmin@centos5 bin]$ java -version
java version "1.6.0_20"
OpenJDK Runtime Environment (IcedTea6 1.9.8) (rhel-1.22.1.9.8.el5_6-i386)
OpenJDK Client VM (build 19.0-b09, mixed mode)
[webadmin@centos5 bin]$
0
wasman
Asked:
wasman
1 Solution
 
xtermCommented:
You're putting the system java binary in the PATH before your own:

  export PATH=$PATH:$JAVA_HOME/bin

Change this to be:

  export PATH=$JAVA_HOME/bin:$PATH

That way it will use yours (the PATH variables always honors the first instance found)
0
 
wasmanAuthor Commented:
Thank you that resolved the issue
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now