Unix: Same executable, different user: different executable version? - macos

I'm being very confused by the following happening in my terminal:
my-computer:~$ which java
/usr/bin/java
my-computer:~$ java -version
java version "1.6.0_65"
Java(TM) SE Runtime Environment (build 1.6.0_65-b14-462-11M4609)
Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-462, mixed mode)
my-computer:~$ sudo su
Password:
my-computer:/Users/paulhabfast$ which java
/usr/bin/java
my-computer:/Users/paulhabfast$ java -version
java version "1.7.0_45"
Java(TM) SE Runtime Environment (build 1.7.0_45-b18)
Java HotSpot(TM) 64-Bit Server VM (build 24.45-b08, mixed mode)
Can anyone explain me what is going on?
The way I understand it so far is that when I switch from the current user to the root user, I'm being served a different executable?
I'm running Mac OSX 10.9, but I thought I had a pretty standard unix environment.
Is there any additional information I can give?

/usr/bin/java is a wrapper that looks at your environment variables, try env to see these variables, for example JAVA_HOME.

Related

while installing hadoop i did the conf part and all after that when i typed hadoop version in cmd it is giving java version

C:\Users\91842>hadoop -version
java version "1.8.0_91"
Java(TM) SE Runtime Environment (build 1.8.0_91-b15)
Java HotSpot(TM) Client VM (build 25.91-b15, mixed mode)

java 11 can not add as jre in spring tool suite version 3.9.7

I am trying to run a simple spring boot project with java 11 but I can not add it as jre. I am getting following error while adding it as jre
I am using following java version on maco os 10.13.16
java version "11.0.2" 2019-01-15 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.2+9-LTS)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.2+9-LTS, mixed mode)
I tried to use the similar path( Contents/Home/lib) for jdk10 and it recognised as jre 10. I think that STS is not able to read jrt-fs.jar for java 11.
Can somebody pleas give some advice?
The JRE home for Java 11.0.2 on macOS is
/Library/Java/JavaVirtualMachines/jdk-11.0.2.jdk/Contents/Home
(no 'lib' at the end)

Java version shows 7 and Java version shows 8 in windows?

I am really frustrated to see following behavior and not sure yet after research how to fixed this. I've two separate projects one works only on Java 7 (can't update to Java 8) and another project works on Java 8 (can't downgrade to 7). So I've both Java 7 and 8 installed on my windows machine.
So, I am seeing following behavior constantly. Currently I am on Java 8 and would like switch back Java 7, so I changed environment variable JAVA_HOME and PATH to point to Java 7, but when I verify through CMD, it shows me following.
C:\>java -version
java version "1.8.0_45"
Java(TM) SE Runtime Environment (build 1.8.0_45-b15)
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)
C:\>javac -version
javac 1.7.0_71
I can't use above combination, neither projects works for me. So I always need to uninstalled Java 8 and then only I can point to Java 7.
Also if I want to move back to Java 8 (again installed Java 8), then it shows me following combination. How to fixed this error on Windows? As uninstalling the JDK every time is not the solution. Please help me.
C:\>java -version
java version "1.7.0_71"
Java(TM) SE Runtime Environment (build 1.7.0_71-b15)
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)
C:\>javac -version
javac 1.8.0_45
java.exe, the Java runtime, also installs in c:\windows or c:\windows\system32 (can't remember, I'm on a Mac now).
So even if your PATH contains the bin directory of JDK, if c:\windows (or c:\windows\system32) comes before JDK\bin in the PATH, the version in c:\windows (or c:\windows\system32) is the one that is used.
Just make sure the JDK is first in the PATH, or at least before c:\windows (or c:\windows\system32).

Unexpected error in checking hadoop version

ubuntu#ubuntu:~$ hadoop -version
java version "1.8.0_20"
Java(TM) SE Runtime Environment (build 1.8.0_20-b26)
Java HotSpot(TM) 64-Bit Server VM (build 25.20-b23, mixed mode)
After running this command, I get this. Unable to crack the problem. Checked all the entries in /.bashrc file. Please help.

OS X Mountain Lion Java version

I would like to use java and javac on Mac OS X 10.8.2, but in the terminal when I ask for version with this command: java -version or javac -version it returns the following versions:
java version "1.6.0_37"
Java(TM) SE Runtime Environment (build 1.6.0_37-b06-434-11M3909)
Java HotSpot(TM) 64-Bit Server VM (build 20.12-b01-434, mixed mode)
and
javac 1.6.0_37
When I go to the settings app and tap on the Java icon in the Other section, it opens the Java Control Panel and there the jre version is 1.7.0_10
Which is used? And how can I update the java in terminal, not to use the 1.6.0 version?
Does anybody experienced this problem?
Open Java Preference App, you may find several JDKs, you can drag JDK7 to the top of the list, then re-open the shell, and invoke java -version. It will change to the JDK7.

Resources