LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Java version not the one I have installed (https://www.linuxquestions.org/questions/linux-general-1/java-version-not-the-one-i-have-installed-870242/)

davholla 03-22-2011 10:22 AM

Java version not the one I have installed
 
I have installed Java 1.6.0
Code:

/usr/local/jdk1.6.0_24/
But I still get the old version
Code:

java -version
java version "1.4.2"
gij (GNU libgcj) version 4.1.2 20080704 (Red Hat 4.1.2-50)

Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE


I know that I need to change my bash_profile but when I try it does not solve the problem


Code:

# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin
PATH=$PATH:/usr/local/jdk1.6.0_24/bin/
export PATH

What am I doing wrong?

SL00b 03-22-2011 10:35 AM

You added your new java path to the end of your path statement, but the previous JDK was already in your path, and is therefore coming up first in your search order.

First, verify your change to .bash_profile has successfully updated your path (I usually make these changes to .bashrc):

Code:

echo $PATH
If so, then go back and reverse the order of your path arguments in .bash_profile so that the new JDK comes up first. I don't see any reason for having multiple path statements, so...

Code:

# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs

export PATH=/usr/local/jdk1.6.0_24/bin:$PATH:$HOME/bin


knudfl 03-22-2011 11:49 AM

A previous java will usually be a link /usr/bin/java to /etc/alternatives/java.

I don't think, the bashrc will override that.

Default install location : /usr/java/jdk1.6.0_24

And the default way of setting up java : 1) su
2)
/usr/sbin/alternatives --install /usr/bin/java java /usr/java/jdk1.6.0_24/bin/java 2

3) /usr/sbin/alternatives --config java
.... Then select version : sun.
....

davholla 03-22-2011 11:53 AM

That fixed it - I mean changing the profile fixed
Code:

# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs

export PATH=/usr/local/jdk1.6.0_24/bin:$PATH:$HOME/bin



All times are GMT -5. The time now is 12:31 PM.