4

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

Error: could not open 'C:\Program Files (x86)\Java\jre7\lib\i386\jvm.cfg'

However, my actual Java path is in D:\Program Files\Java\jdk1.8.0_45\bin. 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)
3
  • 1
    What does the %JAVA_HOME% variable contain? Commented Dec 6, 2015 at 13:47
  • @RealSkeptic `D:\Program Files\Java\jdk1.8.0_45`. %PATH% really just contains %JAVA_HOME%\bin. Commented Dec 6, 2015 at 14:08
  • Could it be that you have an alias for Java somewhere? Try the commands alias and declare -f in your bash sessions and see if they have anything relating to java. Commented Dec 6, 2015 at 14:15

4 Answers 4

5

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:\prgs\git\PortableGit-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:\prgs\git\PortableGit-2.6.3-64-bit>which java.exe
C:\prgs\jdk\jdk-7u51-windows-x64\bin\java.exe

Conclusion: upgrade to the latest git for windows.

Sign up to request clarification or add additional context in comments.

8 Comments

I checked this also -- sorry forgot to mention. C:/Windows/System32 does not contain any of those exes, apart from a file named JavaScriptCollectionAgent.dll.
@Octopod are the PATH or JAVA_HOME environment variables somehow different between your CMD session and your git bash session? What git version are you using?
The two PATH variables are identical aside from the conversion of path separators and such. Git version is 2.5.3.windows.1 according to git version. There doesn't seem to be a trace of Java ever being in where Git Bash is telling me it should be. All my environment variables, user and system, don't contain a Java path besides JAVA_HOME.
@Octopod would JAVA_HOME differs then? (since the PATH refers to %JAVA_HOME%\bin) Just for testing, would a Git 2.63 (github.com/git-for-windows/git/releases/download/…: just unzipped anywhere you want) exhibit the same behavior?
@Octopod Do you have a $HOME/.bashrc which might modify things?
|
1

If you are trying to manually set JDK, then please check if you haven't missed the Oracle Java (C:\ProgramData\Oracle\Java\javapath) in Path Environment Variable under System Variables, remove it and java -version should work just fine.

Comments

0

Check the PATH variable in your .bash_profile file to make sure it reflects the correct version of java. The file is usually in your home directory C:\Users\\{HOME}\\.bash_profile

Comments

0

It will happen when you have running an IDE with another set of JDK instances. The better way to resolve this is set you JDK home in path and make it available in last row. This is working for me.

Windows Env Variable Screen shot

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.