Reputation: 8413
I installed a new JRE 1.7 on my Centos server.
However, when I type in java -version it shows the version 1.6, which means the hosting provider preinstalled that before?
How do I shift it over to the new one 1.7 I installed and make it permanent?
Thank you!
Upvotes: 1
Views: 195
Reputation: 86353
You need to set your PATH
environment variable so that the bin/
directory from your Java installation precedes the system-wide ones. For example, in my user-specific ~/.bashrc
configuration file for the Bash shell I currently have:
export PATH="/usr/java/latest/bin:$PATH"
Note that I prepend (rather than replace) the Java program path to the previous value of the PATH
variable, so that other programs will keep working without requiring the use of absolute paths. As for /usr/java/latest
, it is a symbolic link created by the RPM packages Oracle provides that points to the latest version of Oracle Java installed on my system.
Upvotes: 1
Reputation: 2266
For bash, edit the startup file (~/.bashrc):
PATH=/usr/local/jdk1.7.0/bin:
export PATH
For sh, edit the profile file (~/.profile):
PATH=/usr/local/jdk1.7.0/bin:
export PATH
Source: PATH and CLASSPATH
Upvotes: 1