Highland Mark
Highland Mark

Reputation: 1010

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

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?

Upvotes: 52

Views: 275420

Answers (23)

saigopi.me
saigopi.me

Reputation: 14908

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.

Upvotes: 1

Suraj Khanal
Suraj Khanal

Reputation: 540

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.

Upvotes: 0

Jainender Chauhan
Jainender Chauhan

Reputation: 847

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

Upvotes: 0

Disembleergon
Disembleergon

Reputation: 443

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

Upvotes: -1

Sudhakar Kummarasetty
Sudhakar Kummarasetty

Reputation: 346

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.

Upvotes: 6

Eogcloud
Eogcloud

Reputation: 1365

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!

Upvotes: 11

user1676075
user1676075

Reputation: 3086

  • 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.

Upvotes: 1

Rahul
Rahul

Reputation: 337

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.

Upvotes: 0

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

Upvotes: 93

beloblotskiy
beloblotskiy

Reputation: 1008

Typically it because of upgrading JRE.

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

Intall JDK - it will fix this.

Upvotes: 0

Rookie_Guy
Rookie_Guy

Reputation: 82

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.

Upvotes: -1

Naseer Ahammed
Naseer Ahammed

Reputation: 89

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.

Upvotes: 0

ROMANIA_engineer
ROMANIA_engineer

Reputation: 56626

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"

Upvotes: 1

sivasubramanian
sivasubramanian

Reputation: 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; 

Upvotes: 0

Clinton
Clinton

Reputation: 2837

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.

Upvotes: 20

wutzebaer
wutzebaer

Reputation: 14863

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

Upvotes: 2

Matt
Matt

Reputation: 59

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.

Upvotes: 2

user2668741
user2668741

Reputation: 21

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.

Upvotes: 2

Rudra
Rudra

Reputation: 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.

Upvotes: 0

m_c
m_c

Reputation: 89

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

Upvotes: 0

serganm
serganm

Reputation: 91

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 ;)

Upvotes: 9

deskmore
deskmore

Reputation: 528

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

Upvotes: 47

VonC
VonC

Reputation: 1323753

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 ;)

Upvotes: 3

Related Questions