java command not running from JAVA_HOME on Mac Caralina - java

I installed java 8 and openjdk 11 on my Mac. JAVA_HOME is set to java 8, but when running java --version, it points to openjdk 11. Why is it happens and how can I make java command point to java 8?
running the command
echo $JAVA_HOME
java --version
output is
/Library/Java/JavaVirtualMachines/jdk1.8.0_172.jdk/Contents/Home
openjdk 11.0.8 2020-07-14
OpenJDK Runtime Environment (build 11.0.8+11)
OpenJDK 64-Bit Server VM (build 11.0.8+11, mixed mode)
It is so wired.

export PATH=${JAVA_HOME}:${PATH}
Add this to ~/.zshrc. JAVA_HOME will be the first choice when running java.

Related

conda environment with wrong java version

I created a new conda environment with the command conda create --name condaenv python=2.7 openjdk=8. When I activate this environment using conda activate condaenv and check the java version, however, I get:
openjdk version "1.7.0_91"
OpenJDK Runtime Environment (Zulu 7.12.0.3-linux64) (build 1.7.0_91-b15)
OpenJDK 64-Bit Server VM (Zulu 7.12.0.3-linux64) (build 24.91-b15, mixed mode)
How can I get the correct java version for this conda environment?
I checked that the JAVA_HOME environmental variable is correct, and it is since running echo $JAVA_HOME gives /home/ag956/.conda/envs/condaenv
I solved the issue by first installing Java 1.8 with the command:
conda install -c main java-1.8.0-openjdk-cos7-s390x
And then creating the environment.

How switch java version (SOLVE)

Hi right now on my PC works java 17
C:\Users\Dom>java -version
java version "17.0.4.1" 2022-08-18 LTS
Java(TM) SE Runtime Environment (build 17.0.4.1+1-LTS-2)
Java HotSpot(TM) 64-Bit Server VM (build 17.0.4.1+1-LTS-2, mixed mode, sharing)
I want swap on Java 8 for it in windows environment variables i change path on C:\Program Files\Java\jdk1.8.0_341\bin (like on one guide) but thats not help.
verison java in my pc
- jdk-17.0.4.1
- jdk1.8.0_202
- jdk1.8.0_341
How i can change my java version on Java 8 ?
SOLUTION
in file i type it:
#echo off
echo Setting JAVA_HOME
set JAVA_HOME=C:\Program Files\Java\jdk1.8.0_341
echo setting PATH
set PATH=C:\Program Files\Java\jdk1.8.0_341\bin;%PATH%
echo Display java version
thats change java version

why java version not updated on mac machine?

I checked my java version from terminal .I got this information
Last login: Sun Mar 15 08:46:08 on ttys000
localhost:~ naveenkumar$ java -version
java version "1.7.0_10"
Java(TM) SE Runtime Environment (build 1.7.0_10-b18)
Java HotSpot(TM) 64-Bit Server VM (build 23.6-b04, mixed mode)
localhost:~ naveenkumar$
I install new java 1.8 JRE .close my terminal .Agan i type java -version .I found the same version .
why ? how to upgrade java version.
You installed Java 8 but it didn't overwrite this: /usr/bin/java
The easiest way for you to solve this problem is to install Java 8 JDK, not JRE. After install JDK, your path should be automatically updated.

No Java runtime present, requesting install

I have java JDK installed sucessfully in my mac os 10.9 ..
$ java -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)
But when i try to run eclipse it asks me to jave SE 6 Runtime again !!!
It looks like eclipse is unable to locate the installed java. You can tell eclipse to point to this version of java by modifying eclipse.ini file
In eclipse.ini file, we need to add -vm option to point to the java8 location:
See: http://wiki.eclipse.org/Eclipse.ini#-vm_value:_Mac_OS_X_Example

Cygwin runs different version of java than windows powershell

I have multiple versions of java installed. Recently while testing I noticed that cygwin and powershell were running different versions, and figured it was a problem with my path, but it looks to be something stranger. In powershell I get:
PS C:\Users\djpeaco> echo $env:JAVA_HOME
PS C:\Users\pavon> where.exe java
C:\Windows\System32\java.exe
PS C:\Users\pavon> C:\Windows\System32\java.exe -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)
And then in cygwin (bash):
$ echo $JAVA_HOME
$ which java
/cygdrive/c/Windows/system32/java
$ /cygdrive/c/Windows/system32/java -version
java version "1.7.0_51"
Java(TM) SE Runtime Environment (build 1.7.0_51-b13)
Java HotSpot(TM) Client VM (build 24.51-b03, mixed mode)
I tried restaring both shells, in case there was some environment change that one hadn't picked up, but that didn't solve the problem. Also, cmd.exe behaves the same as powershell. Does anyone know why running the exact same executable in cygwin vs powershell would end up running different JVMs?
Is Cygwin a 32-bit app? It's possible that, if Cygwin is 32-bit, the operating system is redirecting c:\windows\system32 (the real, 64-bit System32 folder) to c:\windows\syswow64 (the 32-bit System32 folder).
Compare java.exe in c:\windows\system32 to java.exe in c:\windows\syswow64. They might be different.

Categories