but if i just java -version it show the old version detail.
When you run this command from your command line, the PATH
environment variable is what the shell will evaluate to determine how to disambiguate your command. If you don't ensure that the new java binary location is in your PATH
, and has a higher precedence than the old one, then the shell has no way of knowing to execute your new java.
Try the following:
$which java //tells you which java command the shell will execute
$echo $PATH //shows you what directories are in your path
$export PATH=/my/new/java/bin/directory:$PATH //set your new java into the PATH env
$java -version
See this tutorial on setting PATH.