51

After years of working OK, I'm suddenly getting this message when trying to start the JVM:

Error: could not open `C:\Program Files\Java\jre6\lib\amd64\jvm.cfg'

I tried uninstalling, and got a message saying a DLL was missing (unspecified) Tried re-installing, all to no avail.

At the same time, when trying to start Scala I get:

\Java\jdk1.6.0_25\bin\java.exe was unexpected at this time.

Checked %JAVA_HOME% and %path% - both OK

Can anyone help?

6
  • 1
    Looks like your JVM got corrupt, or your PATH is polluted. The JVM you think you are running might not be the JVM you should be running. try running java -version to find out if it is 1.6.0_xx.
    – Raze
    May 17, 2011 at 20:34
  • 3
    How is this related to Scala? May 17, 2011 at 20:42
  • 4
    I can't even do java -version without getting the message! May 17, 2011 at 20:55
  • It's related to scala in that scala fails too. Both occurred at the same time. May 17, 2011 at 20:56
  • 1
    here is what i've found in google. Maybe it will help: link
    – tonek
    May 17, 2011 at 21:06

23 Answers 23

93

I checked my environment variables - JAVA_HOME & PATH and they all refer to C:\java. So this was bit frustrating. After sometime I found that the default installation also copied java.exe, javaw.exe and javaws.exe to C:\Windows\System32 (i.e. uninstall of JRE didn't go well). I just removed them and voila, I'm back on track. That annoying error is no longer popping.

This works for me

So, If exists, remove java.exe, javaw.exe and javaws.exe from System32

4
  • 1
    Why Oracle/Sun ever decided to do this and not fix the uninstaller is beyond me. Thank you.
    – makhdumi
    May 11, 2014 at 23:17
  • Just removed the whole folder C:/Windows/jre which allowed the proper java exe farther down the path to be the used. No idea what installed java into my windows dir and put it on the path though :|
    – Deadron
    Aug 11, 2014 at 23:25
  • My situation: Eclipse stopped launching. Proguard wouldn't load due to a missing jvm.cfg file. Removed windows/jre, and the exe files mentioned above. Solved my issue. This just happened seemingly randomly over the last week. No explanation for it.
    – Knossos
    Apr 22, 2015 at 8:10
  • It worked after I removed java.exe, javaw.exe and javaws.exe from C:\Windows\System32. Thanks @Full-Stack Software Engineer. You saved my time. Jun 3, 2020 at 17:30
47

put %JAVA_HOME%\bin at the begin of PATH.

2
  • 4
    Got the same problem on Windows although my PATH and JAVA_HOME was OK. Moving the %JAVA_HOME% to the beginning of the PATH solved it. Thanks!
    – Samuel
    Nov 21, 2012 at 10:33
  • Despite doing this, I was getting the error. What I didn't notice was when I opened a CMD prompt, it would default to C:\Windows\System32, which contained the troublesome java install. Changing out to any other directory would make Java work just fine with the JDK I wanted on the path. Feb 11, 2016 at 20:41
20

Might be a slightly different cause, but that second issue occurs for me in scala 2.9.0.1 on Win7 (x64), though scala-2.9.1.final has already resolved this issue mentioned here:

\Java\jdk1.6.0_25\bin\java.exe was unexpected at this time.

My %JAVA_HOME% set to a path like this: c:\program files(x86)\Java\jdk...

Note the space and the parentheses.

If you change line 24 in %SCALA_HOME%\bin\scala.bat from:

if exist "%JAVA_HOME%\bin\java.exe" set _JAVACMD=%JAVA_HOME%\bin\java.exe

to

if exist "%JAVA_HOME%\bin\java.exe" set "_JAVACMD=%JAVA_HOME%\bin\java.exe"

It works fine. Note the quotes around the set command parameters, this will properly enclose any spaces and 'special' characters (eg: spaces and parentheses) in the variable's value.

Hope this helps someone else searching for an answer.

2
  • 1
    +1, but same treatment should be applied also to the file: %SCALA_HOME%\bin\scalac.bat Dec 14, 2012 at 6:27
  • thanks! in my case, I renamed the Windows partition where Java was installed. Reverting that change fixed it.
    – asgs
    May 29, 2015 at 17:01
10

I had a slight different solution to this problem. my PATH and JAVA_HOME were pointing to JDK12 in

C:\Program Files\Java

but execution of the command:

Java -version

gave the error:

Error: could not open `C:\ProgramFiles\Java\jre1.8.0_212\lib\amd64\jvm.cfg'

I had to delete a folder of executables (Java.exe, javaw.exe etc.) in a different directory than System32, as other answers here and blog posts have suggested. Instead I found the problem lied with executables found in:

C:\Program Files\Common Files\Oracle 

as there was nothing Java related in

C:\Windows\System32

If you're having this issue and nothing is in System32, check this "common files" directory mentioned above for an oracle directory and delete it.

After, your PATH references should work fine!

1
  • 6
    Check at the path "C:\Program Files (x86)\Common Files\Oracle\Java\javapath" as well sometimes, you might have installed some program which silently installed Java. Mar 15, 2020 at 3:51
9

I had the same problem: I have a 64 bit Windows and when I typed "java -version" in CMD-Console i received the same Error message. Try to start a 64bit-cmd(C:\Windows\SysWOW64\cmd.exe) and you will see, it works there ;)

0
7
C:\ProgramData\Oracle\Java\javapath

I took a back up of the files in it and removed those files from there. Then I opened a new cmd prompt and it works like a charm.

0
3

If this was working before, it means the PATH isn't correct anymore.

That can happen when the PATH becomes too long and gets truncated.
All posts (like this one) suggest updating the PATH, which you can test first in a separate DOS session, by setting a minimal path and see if java works again there.


Finally the OP Highland Mark concludes:

Finally fixed by uninstalling java, removing all references to it from the registry, and then re-installing.

scary ;)

6
  • Thanks. Still I can't sort it. With minimal path (path = %JAVA_HOME%\bin) it works - as you say, however, I can't see the problem in the actual path which is "...;%JAVA_HOME%\bin;..." which contains the same thing. May 19, 2011 at 8:37
  • Finally managed to remove old versions of JRE using JavaRA & MSICUU2.exe, reloaded latest version, but still the same message. May 19, 2011 at 9:18
  • 1
    @Highland: if this works with a minimal path but not with a full path, that means %JAVA_HOME%\bin isn't the issue. Some other element in the PATH causes the runtime to fail. Could you try with a PATH you would build, one element at a time, to see when java stop launching?
    – VonC
    May 19, 2011 at 10:32
  • Thanks VonC - that gives me something to work on. I'll report back. May 19, 2011 at 10:50
  • It wasn't in the path. Finally fixed by uninstalling java, removing all references to it from the registry, and then re-installing. None the wiser, but back working again. Thanks all. May 19, 2011 at 15:01
3

I thought I will share how I resolved the same issue "Error Could not open lib\amd64\jvm.cfg". I found the Java run time Jre7 is missing amd64 folder under lib. However, I have 1.7.0_25 JDK which is having jre folder and also having amd64.

I moved the original contents of jre7 folder to a backup file and copied everything from 1.7.0_25\jre.

Now I am not getting this error anymore and able to proceed with scene builder.

2

The Java 7 install on my work PC broke after a patch was forced out to us, giving this error any time you tried to run a Java program. Somehow the entire 'lib' subdirectory of the Java 7 install vanished! Might have been related to having both Java 6 and Java 7 installed -- the 'jre6' directory still had everything there.

In any case, I fixed it by uninstalling both Java 6 and Java 7 and reinstalling just Java 7. But if the file it's complaining about is actually there, then you're likely having a path issue as described in some of the other answers here.

2
  • except in my case reinstalling the JRE did not replace the missing lib folder :(
    – David
    Apr 17, 2014 at 15:26
  • Ah ... I reinstalled the 64-bit JRE, but it turns out there was also a 32-bit JRE installed. I uninstalled both -- they were a couple of patchlevels behind anyway -- then reinstalled the 64-bit JRE (only) and now everything is copacetic.
    – David
    Apr 17, 2014 at 17:58
2

Had suddenly the same Problem, from one day to another eclipse said

Failed to load the JNI shared library "C:/JDK/bin/client/jvm.dll"`.

after trying to run java on the console

Error: could not open `C:\WINDOWS\jre\lib\amd64\jvm.cfg' 

now i just deleted the whole directory

C:\WINDOWS\jre

and everything worked again... i don't know there this jre came from, i hope it was not a virus

1

Another workaround is using shortpath in windows:

  1. open windows command console using cmd.exe
  2. goto c:\
  3. type command> dir program* /x
  4. it should display as short path like: PROGRA~2
  5. so C:\PROGRA~2 is same as C:\Program Files (x86)
  6. in your JAVA_HOME replace path to : C:\PROGRA~2\Java\jre7

This should work in windows 64 environment as it worked for me in win7 64bit version.

1

I have changed the java installation path from c:\Program Files (x86)\java to another folder like c:\java\jdk1.7 and updated the %Java_HOME% and path values accordingly,it worked.

example

%JAVA_HOME% = C:\java\JDK1.7

path-C:\java\JDK1.7\bin; 
1

I had the same problem in Eclipse and I fixed it by changing the JRE from 64 bit to 32 bit:

Window > Preferences > Java > Installed JREs > Add... > Next > Directory > select "C:\Program Files (x86)\Java\jre1.8.0_65" instead of "C:\Program Files\Java\jre1.8.0_60"

1
  • This issue occurred to me while installing eclipse. I was installing eclipse after JAVA update where my earlier version was 1.8.0_60 and the newer version was 1.8.0_191 which i guess is changed while installing update so i changed folder name to earlier i.e. 1.8.0_60 . So the issue is with post install script of JAVA update i guess @ time of Update installation both names should be changed by install which is not the case. i.e. minor change is remaining after post install of java update.
    – Rahul
    Nov 15, 2018 at 17:31
1
  • I had a similar problem (trying to start a Jenkins slave agent on Windows) on Windows 2008R2, Java 1.7.0_15

  • I had two situations that contributed to the problem and that changing both of them fixed it:

    1) Installing Java in a unix-compatible path (changing from c:\Program Files\... to c:\Software\...); I don't think this directly affected the problem described in this thread, but noting the change;

    2) Running Java not through a shortcut. It originally failed with a shortcut, but re-running from the direct executable (C:\Software\Java...\bin\java) worked.

1

I kept variable name as "Path" but it did not work after changing it to "PATH" started working for me.

variable name: PATH

variable value: C:\Program Files\Java\jdk-19\bin

this will work.

0

Reinstalling java didn't help me. But the trick to put the JAVA_HOME variable at the beginning of the env-vars. The problem occoured after an upgrade from jdk1.7.0_11 to jdk1.7.0_13

0

I had this problem after updating your java. The best way to solve this problem is just go to your c:/ProgramFiles/Java folder. There you will find two jre folders one is as jre.your version and other with exactly like jdk folder. Try to remove jre.1.your version folder. There you go your problem is solved. Hope this might help. It's worked for me.

0

Typically it because of upgrading JRE.

It changes symlinks into C:\ProgramData\Oracle\Java\javapath\

Intall JDK - it will fix this.

0
Error: could not open `C:\Program Files\Java\jre6\lib\amd64\jvm.cfg'

Looking @ it the issue of post install script is there and getting propagated since I am using update jdk8 1.8.0_191 since issue occurred with me after installing update of java and which was happened automatically.

Error: could not open `C:\Program Files\Java\jre1.8.0_191\lib\amd64\jvm.cfg'

This will be never ending in this case and need to do workaround like changing path's manually.

0

Delete the jars under system32 for windows. Delete the jars under C:\Program Files\Common Files\Oracle

Edit the environment variable set JAVA_HOME and SET PATH to bin

0

I have solved this issue by deleting the Oracle folder from Program Data. And also delete the oracle java path associated with that folder from environment variables.

-1

It wasn't in the path. Finally fixed by uninstalling java, removing all references to it from the registry, and then re-installing. None the wiser, but back working again. Thanks all @Highland Mark- Can you tell me the process to removing references from registry. I tried all possible way people mentioned here, nothing worked.

-1

If you have downloaded several Jdks you have to delete all except of the JDK you want to use!

Not the answer you're looking for? Browse other questions tagged or ask your own question.