Skip to content
Advertisement

Why is Git Bash not using the correct Java path as defined in the PATH environment variable?

In an instance of Git Bash, typing in java -version gives me:

Error: could not open 'C:Program Files (x86)Javajre7libi386jvm.cfg'

However, my actual Java path is in D:Program FilesJavajdk1.8.0_45bin. This is shown in my %PATH% variable if I type in either echo $PATH or env | grep PATH.

Where is Git Bash getting this nonexistent Java path from?

P.S.

To add on to this, running java -version in the Command Prompt gives me the correct output:

java version "1.8.0_45"
Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)

Advertisement

Answer

Check if you have some old java.exe, javaw.exe, javaws.exe in the c:/windows/system32 folder, as mentioned in “Java path..Error of jvm.cfg“.

I just checked with Git 2.6.3 on Windows, where I don’t have anything in c:/windows/system32, and the result is consistent between:

git bash:

vonc@bigvonc MINGW64 /
$ java -version
java version "1.7.0_51"
Java(TM) SE Runtime Environment (build 1.7.0_51-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.51-b03, mixed mode)

and CMD:

C:prgsgitPortableGit-2.6.3-64-bit>java -version
java version "1.7.0_51"
Java(TM) SE Runtime Environment (build 1.7.0_51-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.51-b03, mixed mode)

Both report the same java at the same spot:

vonc@bigvonc MINGW64 /
$ which java
/c/prgs/jdk/jdk-7u51-windows-x64/bin/java

C:prgsgitPortableGit-2.6.3-64-bit>which java.exe
C:prgsjdkjdk-7u51-windows-x64binjava.exe

Conclusion: upgrade to the latest git for windows.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement