运行 Java 会出现“错误:无法打开 `C:\Program Files\Java\jre6\lib\amd64\jvm.cfg””

发布于 2024-11-07 12:32:30 字数 390 浏览 1 评论 0原文

经过多年的正常工作后,我在尝试启动 JVM 时突然收到此消息:

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

我尝试卸载,并收到一条消息说缺少 DLL(未指定) 尝试过重新安装,都没有效果。

同时,当尝试启动 Scala 时,我得到:

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

Checked %JAVA_HOME% and %path% - both OK

有人能帮忙吗?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(23

意中人 2024-11-14 12:32:30

我检查了我的环境变量 - JAVA_HOME & PATH 并且它们都引用 C:\java。所以这有点令人沮丧。一段时间后我发现默认安装也将java.exe、javaw.exe和javaws.exe复制到C:\Windows\System32(即JRE卸载不顺利)。我刚刚删除了它们,瞧,我又回到了正轨。那个烦人的错误不再弹出。

这对我有用

所以,如果存在,请从 System32 中删除 java.exe、javaw.exe 和 javaws.exe

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

若有似无的小暗淡 2024-11-14 12:32:30

将 %JAVA_HOME%\bin 放在 PATH 的开头。

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

心不设防 2024-11-14 12:32:30

可能是一个稍微不同的原因,但第二个问题发生在 Win7 (x64) 上的 scala 2.9.0.1 中,尽管 scala-2.9.1.final 已经解决了这里提到的这个问题:

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

我的 %JAVA_HOME% 设置为如下路径: c:\program files(x86)\Java\jdk...

注意空格和括号。

如果将 %SCALA_HOME%\bin\scala.bat 中的第 24 行从: 更改

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

为 则

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

效果很好。请注意 set 命令参数周围的引号,这将正确地将变量值中的任何空格和“特殊”字符(例如:空格和括号)括起来。

希望这可以帮助其他人寻找答案。

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.

在风中等你 2024-11-14 12:32:30

我对这个问题有一个稍微不同的解决方案。我的 PATH 和 JAVA_HOME 指向 JDK12,

C:\Program Files\Java

但执行命令:

Java -version

给出错误:

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

我必须在与 System32 不同的目录中删除可执行文件的文件夹(Java.exe、javaw.exe 等),正如其他答案here 和博客文章已建议。相反,我发现问题出在以下位置的可执行文件上:

C:\Program Files\Common Files\Oracle 

因为没有任何与 Java 相关的内容

C:\Windows\System32

如果您遇到此问题,并且 System32 中没有任何内容,请检查上面提到的“公共文件”目录中的 Oracle 目录并将其删除。

之后,您的 PATH 引用应该可以正常工作!

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!

小嗷兮 2024-11-14 12:32:30

我遇到了同样的问题:我有一个 64 位 Windows,当我在 CMD-Console 中输入“java -version”时,我收到了相同的错误消息。
尝试启动 64 位 cmd(C:\Windows\SysWOW64\cmd.exe),你会发现它在那里工作;)

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

病女 2024-11-14 12:32:30
C:\ProgramData\Oracle\Java\javapath

我备份了其中的文件并从那里删除了这些文件。然后我打开了一个新的命令提示符,它就像一个魅力。

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.

任谁 2024-11-14 12:32:30

如果这之前有效,则意味着 PATH 不再正确。

PATH 变得太长并被截断时,就会发生这种情况。
所有帖子(例如 这个)建议 更新 PATH,您可以首先在单独的 DOS 会话中进行测试,设置最小路径,然后查看 java 是否再次工作。


最后,OP Highland Mark 总结道:

最终通过卸载 java、从注册表中删除对它的所有引用,然后重新安装来修复。

可怕的 ;)

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

林空鹿饮溪 2024-11-14 12:32:30

我想我会分享如何解决同样的问题“错误无法打开 lib\amd64\jvm.cfg”。我发现Java运行时Jre7缺少lib下的amd64文件夹。但是,我有 1.7.0_25 JDK,它有 jre 文件夹,也有 amd64。

我将 jre7 文件夹的原始内容移至备份文件,并复制 1.7.0_25\jre 中的所有内容。

现在我不再收到此错误,并且能够继续使用场景生成器。

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.

悲喜皆因你 2024-11-14 12:32:30

在强制向我们提供补丁后,我的工作 PC 上安装的 Java 7 崩溃了,每当您尝试运行 Java 程序时都会出现此错误。不知何故,Java 7 安装的整个“lib”子目录消失了!可能与同时安装了 Java 6 和 Java 7 有关——“jre6”目录中仍然包含所有内容。

无论如何,我通过卸载 Java 6 和 Java 7 并仅重新安装 Java 7 来修复它。但是,如果它所抱怨的文件确实存在,那么您可能会遇到路径问题,如此处的其他一些答案中所述。

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.

悍妇囚夫 2024-11-14 12:32:30

突然遇到了同样的问题,从一天到另一个日食,

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

在尝试在控制台上运行java后

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

说,现在我刚刚删除了整个目录

C:\WINDOWS\jre

,一切又恢复了...我不知道这个jre来自哪里,我希望它是不是病毒

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

贪恋 2024-11-14 12:32:30

我在 Eclipse 中遇到了同样的问题,我通过将 JRE 从 64 位更改为 32 位 来修复它:

Window >首选项>爪哇>安装的 JRE >添加...>>下一页>目录>选择“C:\Program Files (x86)\Java\jre1.8.0_65”而不是“C:\Program Files\Java\jre1.8.0_60”

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"

孤云独去闲 2024-11-14 12:32:30
  • (尝试在 Windows 上启动 Jenkins 从代理)

  • 我遇到了两种导致该问题的情况,并且都更改了他们修复了它:

    1) 在 unix 兼容路径中安装 Java(从 c:\Program Files\... 更改为 c:\Software\.. .);我认为这不会直接影响该线程中描述的问题,但请注意更改;

    2) 不通过快捷方式运行Java。它最初因快捷方式而失败,但从直接可执行文件(C:\Software\Java...\bin\java重新运行成功了。

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

香草可樂 2024-11-14 12:32:30

我将变量名称保留为“路径”,但将其更改为PATH”后不起作用
开始为我工作。

变量名称: PATH

变量值: C:\Program Files\Java\jdk-19\bin

这将起作用。

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.

帅冕 2024-11-14 12:32:30

重新安装java对我没有帮助。但是将 JAVA_HOME 变量放在环境变量的开头的技巧。从jdk1.7.0_11升级到jdk1.7.0_13后出现该问题

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

芸娘子的小脾气 2024-11-14 12:32:30

另一个解决方法是在 Windows 中使用短路径:

  1. 使用 cmd.exe 打开 Windows 命令控制台
  2. goto c:\
  3. type command> dir program* /x
  4. 它应该显示为短路径,例如:PROGRA~2
  5. 因此 C:\PROGRA~2相同 C:\Program Files (x86)
  6. JAVA_HOME 中的 路径替换为:
    C:\PROGRA~2\Java\jre7

这应该适用于 Windows 64 环境,因为它适用于我的 win7 64 位版本。

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.

沫雨熙 2024-11-14 12:32:30

我已将 java 安装路径从 c:\Program Files (x86)\java 更改为 c:\java\jdk1.7 等另一个文件夹,并更新了 %Java_HOME% 和相应的路径值,它起作用了。

例子

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

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

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; 
一城柳絮吹成雪 2024-11-14 12:32:30

更新java后我遇到了这个问题。解决此问题的最佳方法就是转到您的 c:/ProgramFiles/Java 文件夹。在那里你会发现两个 jre 文件夹,一个是 jre.your 版本,另一个与 jdk 文件夹完全相同。尝试删除 jre.1.your 版本文件夹。到这里你的问题就解决了。希望这可能有所帮助。这对我有用。

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.

注定孤独终老 2024-11-14 12:32:30

通常是因为升级了 JRE。

它将符号链接更改为 C:\ProgramData\Oracle\Java\javapath\

Intall JDK - 它将修复此问题。

Typically it because of upgrading JRE.

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

Intall JDK - it will fix this.

九公里浅绿 2024-11-14 12:32:30
Error: could not open `C:\Program Files\Java\jre6\lib\amd64\jvm.cfg'

看看@它,安装后脚本的问题就在那里并且正在传播,因为我使用更新jdk8 1.8.0_191,因为在安装java更新后我出现了问题,并且这是自动发生的。

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

在这种情况下,这将永远不会结束,需要采取解决方法,例如手动更改路径。

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.

爱的故事 2024-11-14 12:32:30

删除windows下system32下的jar包。
删除 C:\Program Files\Common Files\Oracle 下的 jar

编辑环境变量 set JAVA_HOME 并将 SET PATH 设置为 bin

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

把梦留给海 2024-11-14 12:32:30

我通过从程序数据中删除 Oracle 文件夹解决了这个问题。并从环境变量中删除与该文件夹关联的 oracle java 路径。

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.

尽揽少女心 2024-11-14 12:32:30

它不在路上。最后通过卸载 java,从注册表中删除对它的所有引用,然后重新安装来修复。尽管如此,还是又回去工作了。谢谢大家@Highland Mark-你能告诉我从注册表中删除引用的过程吗?我尝试了这里提到的所有可能的方法,但没有任何效果。

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.

风吹雪碎 2024-11-14 12:32:30

如果您下载了多个 Jdks,则必须删除除您要使用的 JDK 之外的所有 Jdks!

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文