注册表项“ ...”的值为“1.7”,但需要“1.6”。Java1.7已经安装,注册表正在指向它

我的开发团队最近被迫转移到一个远程开发环境,在那里我们无法完全访问服务器。在更改之前,我们有一个在 Java 1.7 x64和 JRE 7上运行良好的 JAR。当我们转移到新服务器时,我们的 JAR 运行正常,但是其中一个服务器管理员“更新”了我们的 Java 到旧版本,并卸载了我们正在使用的版本。别问我为什么,我不知道。我重新安装了 Java 1.7,卸载了1.6和 JRE。

在运行时发生以下问题,不存在生成错误:

Registry key 'Software\JavaSoft\Java Runtime Environment\CurrentVersion'
has value '1.7', but '1.6' is required.
Error: could not find java.dll
Error: could not find Java SE Runtime Environment.

我已经在笔记本电脑上运行了相同的 JAR,没有任何问题。服务器和我的膝上型电脑在各自的% HOME% 变量和系统 PATH 中都有 JDK 1.7和 JRE 7。我甚至重新安装了 JRE6,并将其放置在系统环境 PATH 变量中,得到了相同的结果。

我还将注册表修改为1.6,结果如下,我查了一下,似乎是因为安装了多个 Java (导致了我最初的问题) :

Exception in thread "main" java.lang.UnsupportedClassVersionError: ... :
Unsupported major.minor version 51.0

我会很感激你们所有的洞察力,因为我一直在寻找各种论坛,但似乎没有什么具体的问题。此外,这也发生在我们正在使用的另一台服务器上。谢谢!

更新: 无法将 JAR 重新编译为1.6或1.7并匹配 JDK。另外,为什么新版本的 Java 会破坏旧的编译版本呢?

137242 次浏览

The jar was compiled to be 1.6 compliant. That is why you get this error. Two resolutions:
1) Use Java 1.6

OR

2) Recompile the jar to be compliant for your environment 1.7

This happens when you somehow confused java itself. You are trying to run a java 6 VM where it found a JRE 7. It might show this problem even if you type in the command line just java or java -version in a misconfigured environment. The JAR is not the problem, except in the very unlikely case where the code in JAR is looking in the Windows Registry for that (which probably is not your case).

In my case, I had the java.exe, javaw.exe and javaws.exe from Java 6 in the Windows/System32 folder (don't know how it got to be there). The rest of the JDK and JRE where found in the PATH inside C:\Java\jdk_1.7.0\bin. Oops!

I don't know if anyone is still following this thread, but I recently had this issue when I tried to launch ActiveMQ 5.10 as a Windows service.

I didn't have a JAVA_HOME path set. I had Java 6 and Java 7 installed, but the default version was v7. (ie if I opened a command window and types "java -version").

This is where the clue was - "java -version" returned "Java HotSpot(TM) 64-Bit Server VM (build 23.1-b03, mixed mode)" but I was had installed the Win32 service...

It turns out that if you use the Win32 wrapper on a 64-bit machine it somehow decides to use a different version of Java...

So my fix was to uninstall the 32-bit version of the wrapper and install the 64-bit version. aversion on my machine; just habit I guess... But luckily I resolved the issue eventually...

Using regedit, remove the entries corresponding to java 7. It will work.

I've deleted java files at windows/system32 and I also have removed c:\ProgramData\Oracle\Java\javapath from the PATH variable, because there was 3 symlinks to java 1.8 files.

I had JDK 1.7 in the %JAVA_HOME% variable and java1.7/bin in the PATH.

PS1: My problem was between Java 1.7 and Java 1.8.

PS2: I can't add this as a comment to Victor's answer because I haven't enough points.

Just had the similar error when installing java 8 (jdk & jre) on a system already running Java 7.

Error: Registry key 'Software\JavaSoft\Java Runtime

Environment'\CurrentVersion' has value '1.8', but '1.7' is required.

Error: could not find java.dll Error: Could not find Java SE Runtime Environment.

My environment was set up correctly (Path & java_home correctly defined), but the problem arises from the way pre-8 Java installers worked, which is that they used to copy the three executables (java.exe, javaw.exe & javaws.exe) to the Windows system directory. These remain unless overwritten by a new pre-8 installation.

However the Java 8 installer instead creates symbolic links in a new directory, C:\ProgramData\Oracle\Java\javapath, pointing to the actual JRE 8 location.

This means that you'll actually run the old 7 exes but use the new 8 DLLs.

So, the solution is simply to delete the 3 Java exes, as above, from the windows system directory.

If you are running 32-bit Java on a 64-bit Windows, the exes would be in Windows\SysWOW64, otherwise in Windows\System32.

For my Win7

Paradox was in being java.exe and javaw.exe in System32 folder. Opening that folder I couldn't see them but using search in Start menu I get links to those files, removed them. Next searsh gave me links to files from JAVA_HOME

magic )

I solved this problem by uninstalling Java 1.8

In the START menu type "regedit" to open the Registry editor

Go to "HKEY_LOCAL_MACHINE" on the left-hand side registry explorer/tree menu

Click "SOFTWARE" within the "HKEY_LOCAL_MACHINE" registries

Click "JavaSoft" within the "SOFTWARE" registries

Click "Java Runtime Environment" within the "JavaSoft" list of registries here you can see different versions of installed java

Click "Java Runtime Environment"- On right hand side you will get 4-5 rows . Please select "CurrentVersion" and right Click( select modify option) Change version to "1.7"

Now the magic has been completed

Change to directory with correct java.exe i.e. go to the required JDK version java.exe

cd C:/Program Files/Java/jdk1.7.0_25/bin

Run the java.exe from this directory, it has precedence over registry and $PATH settings.

java -jar C:/installed/selenium-server-standalone-2.53.0.jar