0

On my Red Hat server, java -version outputs;

$ java -version 
java version "1.6.0_27"
Java(TM) SE Runtime Environment (build 1.6.0_27-b07)
Java HotSpot(TM) 64-Bit Server VM (build 20.2-b06, mixed mode)
$ 

However, neither PATH, nor JAVA_HOME environment variables are set. Likewise, JAVA_HOME is not set on ~/.bash* files.

Why and how my server uses this version of Java while two other versions of Java are installed as well?

xlecoustillier
  • 16,183
  • 14
  • 60
  • 85
Yiğit
  • 160
  • 1
  • 1
  • 8

2 Answers2

4

Firstly, JAVA_HOME is not involved in this. (JAVA_HOME is used conventionally by wrapper scripts, etc for applications that use Java ... but not by any of the Java executables themselves.)

Second, you are probably running java via a symlink managed by the alternatives program. (RHEL and similar distros use this utility to allow you to select different versions of utilities installed on the same system.)

Either way, running the following will help you figure out what is going on.

$ ls -l `which java`

(Then following the chain of symlinks until you get to the actual executable.)

Stephen C
  • 698,415
  • 94
  • 811
  • 1,216
0

Which executable runs depends on PATH variable. Double check it. It can't run if not set it is impossible unless you have some strange Linux config.

If Java executable is in current directory, it would run by ./java. Since it runs with just java it is somewhere in the PATH.

Suzan Cioc
  • 29,281
  • 63
  • 213
  • 385