• Post Reply Bookmark Topic Watch Topic
  • New Topic

openjdk "java" command running Instead of oracle version  RSS feed

 
Nikolas Nikolaou
Ranch Hand
Posts: 101
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi.
I've Installed oracle JDK version 1.8 on a debian machine that already has openjdk 1.6.i've set the path variable in etc/login.defs and java_home variable In etc/environment.
When I echo $JAVA_HOME it points to the oracle version correctly and when I run javac It uses the oracle 1.8 version.
The problem is when I run the java command , It runs the openjdk 1.6 version and I'm not sure why.If I type java -version It shows the openjdk version.
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to add the $JAVA_HOME/bin directory to the PATH.

Probably your OpenJDK installation is now in the PATH before the Oracle Java 8 installation, so that when you run java, the OpenJDK version is found first.
 
fred rosenberger
lowercase baba
Bartender
Posts: 12565
49
Chrome Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
when you type something on the command line, the OS has to figure out where the program is you want to run. The PATH variable is a list of directories the OS will search for your command. There may be some subtleties involved, but basically, it search each directory listed, in the order you have them listed, until it finds a match. If you have multiple version of java installed, or even the java.exe in multiple directories, the OS stops looking as soon as it finds ANY java.exe.

So echo your PATH, and you will find the 1.6 directory before the 1.8
 
Nikolas Nikolaou
Ranch Hand
Posts: 101
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks! I thought It wasn't set In the $PATH
I was looking for /usr/lib/jvm but It appears to also be In /usr/sbin

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!