简体   繁体   中英

Registry key Error: Java version has value '1.8', but '1.7' is required

While running

sencha app build production

I am getting the following error:

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.

java -version , command is showing following:

java version "1.8.0_40" Java(TM) SE Runtime Environment (build 1.8.0_40-b26) Java HotSpot(TM) 64-Bit Server VM (build 25.40-b25, mixed mode)

Not able to find where path is going wrong. Any idea?

----------------------- EDIT ------------------------------------------------

Note : I am using Windows 7 (64 bit).

I have tried uninstalling the sencha touch cmd and reinstalling. But still same error.

I have uninstalled all the java version instances and reinstalled the latest one, Still the problem persist.

After trying more than hundred of tricks, finally got success.

I removed all java.exe , javaw.exe and javaws.exe from my

  1. Windows\System32 and

  2. Windows\SysWOW64 folder. [Try step 2 if you have x64 system (Win 7 64 bits)]

In my case (Windows 7 64-bit), I just did the following:

  • Removed the reference to C:\ProgramData\Oracle\Java\javapath; from the Path environment variable
  • Removed files java , javaw and javaws from the C:\Windows\System32 folder

Afterwards, I closed all open command line consoles, reopened them and ran java -version .

  1. open regedit
  2. go to [HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment]
  3. change value CurrentVersion from "1.8" to "1.7"

re: Windows users

No. Don't remove the Javapath environment reference from your PATH variable.

The reason why the registry didn't work is that the Oracle Javapath script needs to run in the PATH sequence ahead of the JRE & JDK directories - it will sort out the current version:

put this directory at the HEAD of your %PATH% variable:

C:\ProgramData\Oracle\Java\javapath

[or wherever it is on your desktop]

so your PATH will look something like this - mine for example

PATH=C:\ProgramData\Oracle\Java\javapath;<other path directories>;E:\Program Files\Java\jdk1.8.0_77\bin;E:\Program Files\Java\jre1.8.0_77\bin

You will then see the correct, current version:

C:\>java -version
java version "1.8.0_77"
Java(TM) SE Runtime Environment (build 1.8.0_77-b03)
Java HotSpot(TM) 64-Bit Server VM (build 25.77-b03, mixed mode)

My experience:

I am using windows 8.1 and i have downgraded JAVA version from 1.8 to 1.7 and i was getting the same error.

Error: Registry key 'Software\JavaSoft\Ja has value '1.7', but '1.8' is required.

I have deleted java.exe , javaw.exe and javaws.ex e from C:\Windows\System32 folder and it worked for me.

I've had the same problem. Simple solution that worked for me is to rearrange the entries in the PATH for JRE/JDK . This problem started to appear after installing JRE 8 whose installation has put some executable files in System32 or SysWOW64 directories, these executable files are messing up. To resolve the problem:

  1. Create environment variable pointing to JDK home as JAVA_HOME .

    set JAVA_HOME=C:\Progra~1\Java\jdk1.8.0_45

  2. Put the entry %JAVA_HOME%\bin at start in your PATH environment variable. Appending existing value of PATH . For example:

    path=C:\Program Files\Java\jdk1.8.0_45\bin;%path%

I didn't delete any of the java.exe files, but changed the ordering of my System - "path" variable - so that it reflected %JAVA_HOME%\bin as the first entry. That did the trick.

The error is explicit ...

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.

... you are attempting to use the java.exe 1.7 executable while the HKEY_LOCAL_MACHINE\Software\JavaSoft\Java Runtime Environment > CurrentVersion registry key has the value 1.8.

The recurring theme to proposed solutions is that the error is a configuration error . The error can be solved in various different manners (eg reconfiguration of the users environment or removal of java executables with fingers-crossed and hope that there exists another fallback java.exe in the users %PATH% and that the fallback java.exe is the correct executable).

The correct solution depends on what you're trying to achieve: "are you trying to downgrade from jdk-8 to jdk-7? Are trying to upgrade to jdk-8? ..."

Reproduction steps

  1. install jdk-7u80-windows-x64.exe

notes:

  • the java.exe executable available in the users %PATH% is installed in C:\Windows\System32
  • the installation does not update the users %PATH%
  • the HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment > CurrentVersion string registry entry is created (among others) with the value 1.7
  1. install jdk-8u191-windows-x64.exe

notes:

  • the users %PATH% is updated to include C:\Program Files (x86)\Common Files\Oracle\Java\javapath as the first entry
  • the the HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment > CurrentVersion string registry entries value is updated to 1.8
  1. update the users %PATH% environment variable, remove C:\Program Files (x86)\Common Files\Oracle\Java\javapath

  2. in a new command prompt java -version

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.

Solution(s)

  1. OP's solution https://stackoverflow.com/a/29769311/1423507 is a "fingers-crossed and hope that there exists a fallback java.exe in the users %PATH% and that the fallback executable is correct" approach to the error. Given the reproduction steps, removing the java.exe , javaw.exe and javaws.exe executables from C:\Windows\System32 (only in my case) will result in no longer having any java.exe present in the users %PATH% resulting in the error 'java' is not recognized as an internal or external command, operable program or batch file. which is not so much of a solution.

  2. answers https://stackoverflow.com/a/35775493/1423507 and https://stackoverflow.com/a/36516620/1423507 work however you're reverting to using java.exe 1.7 (eg update the CurrentVersion registry key's value to match the java.exe version found in the users %PATH% ).

  3. make sure java.exe 1.8 is the first found in the users %PATH% (how you do that is irrelevant) ie:

    • update the users %PATH% to include C:\Program Files (x86)\Common Files\Oracle\Java\javapath first (ensure that the executables in that directory are correct)
    • update the users %PATH% to include the absolute path of your java binaries first ( set PATH="C:\Program Files\Java\jre1.8.0_191\bin;%PATH%" )
    • set java specific environment variables and update the users %PATH% with them ( set JAVA_HOME="C:\Program Files\Java" ; set JRE_HOME=%JAVA_HOME%\jre1.8.0_191 ; set PATH=%JRE_HOME%\bin;%PATH% )

I had this error on some windows services running Java. In the end, on my machine I tried to uninstall the other versions of java.

I left only 1.8 and now everything is working.

aribeiro answer has worked for me - with minor changes

  • I Removed the reference to C:\ProgramData\Oracle\Java\javapath; from the Path environment variable
  • I made /path/to/jdkhome as the first entry in my PATH environment variable. I think this alone is all that is needed.

As for me on win7 64bit.

Copy the java.exe javaw.exe javaws.exe in the folder C:\Program Files\Java\jre1.8.0_91\bin to the C:\Windows\System32.

and then open cmd, type java -version.

C:\Users\HEcom>java -version
java version "1.8.0_91"
Java(TM) SE Runtime Environment (build 1.8.0_91-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.91-b14, mixed mode)

Before the above make sure the Registry's CurrentVersion is 1.8

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

  1. Go to "HKEY_LOCAL_MACHINE" on the left-hand side registry explorer/tree menu
  2. Click "SOFTWARE" within the "HKEY_LOCAL_MACHINE" registries
  3. Click "JavaSoft" within the "SOFTWARE" registries
  4. Click "Java Runtime Environment" within the "JavaSoft" list of registries here you can see different versions of installed java
  5. Click "Java Runtime Environment"- On right hand side you will get 4-5 rows . Please select "CurrentVersion" and right Click( select modify option) make sure the version is "1.8"

My solution for this problem came after reading and trying all of the above.

In my case I tried to downgrade Java to use printouts in Apache ActiveMQ . After uninstalling all Java versions and cleaning the registry I was getting the same error

Error: Registry key 'Software\JavaSoft\Java Runtime Environment'\CurrentVersion' has value '1.7', but '1.8' is required."

In my case I needed to go to environment variables, edit path, open the javapath location ( C:\ProgramData\Oracle\Java\javapath ) and there it was - three files ( java.exe , javaw.exe , javaws.exe ) that remained from the JRE8 version.

After establishing this fact I simply switched them with the same files from C:\Windows\SysWOW64 directory (those were from the JRE7 version) and it all worked perfectly.

After the latest automatic Java update, I could not run Java from the command prompt.

My path variable had 'C:\ProgramData\Oracle\Java\javapath;'

I could not cd into 'C:\ProgramData\Oracle\Java\javapath;' from the command prompt window, since it did not exist.

I removed C:\ProgramData\Oracle\Java\javapath;' from the path variable and replaced it with 'C:\Program Files\Java\jre1.8.0_141\bin;'

You have to define your jdk folder in variable JAVA_HOME, add %JAVA_HOME% to your variable path

Delete or change name of your java.exe, javaw.exe and javaws in your folder system32

execute cmd.exe, java -version now take the new version that you define in JAVA_HOME.

In addition to Anand Gupta's answer, make sure no other java except for the one you need is used. Run which java ( where java for Windows) and see which java executables are used. Just delete the ones you don't want to use and if the one you need is not present, add it to PATH.

First you should have Java 7. If you don't have, install it first (I don't know what you are using, Linux, Mac, yum, apt, homebrew, you should find out yourself.)

If you already have Java 7, run:

echo $JAVA_HOME

Output should be something like this: /usr/lib/jvm/java-8-oracle . Near this directory, you should see java-7 directory. After you found it, run

export JAVA_HOME=${java-7-dir}

Change {java-7-dir} with your directory path. Then you can run your command.

This is only a temporary solution. To change it permanently, put the above command to your ~/.bashrc file.

EDIT: If you are using Windows , change environment variable of JAVA_HOME to your Java 7 installation directory path.

My short contribution, for sharing the same problem with Talend Open Studio 64 bit version.

  1. Launch ..\TOS_DI-Win32-20150702_1326-V6.0.0\TOS_DI-win-x86_64.exe manually (not link an startup Windows menu)
  2. and this registry error message appears

To resolve this, remove all java.exe, javaw.exe and javaws.exe files on c:\ProgramData\Oracle\Java\javapath\

and TOS start with 64 bits version correctly !

Remove it from the System path:

%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem

And it will fix the issue in upgrading java version from 1.7 to 1.8

There exist somewhere another java.exe from jre version 1.8 that it is in "path" you should find and delete it if it is possible. it may be in user tempdata for applications that need jre.

Please change JAVA_BIN and JAVA_HOME system variable, and then restart system or maybe relogin. You are having that error because it is still jdk1.7 path. On windows it is like this: 在此处输入图像描述

I have had the similar problem. Moving the JDK and JRE path to the top of the path variable solved the problem (which takes first priority over what is present under System32)

For example, here is mine:

在此处输入图像描述

Just Install Java SE Runtime Environment JRE 7 !

Now you see "java 7" & "java 8" in "Programs and Features" in the "Control Panel"

It worked for me.

One possible solution to this problem is to add at Sencha CMD folder a bat file as sugested at this thread Sencha Cmd 5 + Java 8 Error .

The batch will have the name "sencha.bat" with this code:

@echo off
set JAVA_HOME=<YOUR JDK 7 HOME>
set PATH=%JAVA_HOME%\bin;%PATH%
set SENCHA_HOME=%~dp0
java -jar "%SENCHA_HOME%\sencha.jar" %*

Place it at sencha folder, in my case is

C:\Users\<YOUR USER>\bin\Sencha\Architect\Cmd\6.2.0.103

The following step is to change PATHEXT enviroment varible. Change at user variables to have the least impact possible.

I change from

COM;.CMD;.EXE;.BAT;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC

to

COM;.BAT;.EXE;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC

The idea is to make windows run .bat files first than .exe files. This is important because in sencha folder there is already an "sencha.exe" file. And in the command line if you type "sencha" it will execute "sencha.exe" instead of "sencha.bat".

This was the only solution that worked for because I'm very restricted when it comes to permissions.

My System:- Windows 8.1

Java Environments

  • C:\JavaEnvironment\Java\jdk1.8.0_161
  • C:\JavaEnvironment\Java\jdk1.7.0_75

I recently installed Oracle 11g XE and I received the mentioned error message when accessed "java" command at command prompt.

I checked my environment variables, checked the sequence (as mentioned by previous replies) and detected that my system PATH variable had following entry as first entry:

C:\OracleDatabase\oraclexe\app\oracle\product\11.2.0\server\bin;

I changed the sequence and defined JDK path as first entry:

在此处输入图像描述

I replicated the same change to User Variable: Path

在此处输入图像描述

After finishing the above activity, I restarted the command prompt and executed java -version command and the problem had vanished. It displayed Java 8 as the current version.

I faced this issue but this was because i opened the command prompt ( windows machine ) and by default it opened the command prompt at :

C:\WINDOWS\system32>

trying to execute basic command such as java -version would give me this error :

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.

Simply navigating out of system32 into C:\ and voila ! things are working ( guess in my case it was to do with being present inside system32 which would be a windows specific directory )

我还在 Windows 注册表中找到了以下键,更改它解决了我的问题:

Computer\HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\JavaSoft\Java Runtime Environment\CurrentVersion

Unistall Java 8 from your program list. BY following below steps:-

From your desktop, click on the Start Menu (or Start ball) at the lower left of your screen. Go to the Control Panel. Click on Programs and Features. Select Java8 and click Uninstall

Kill all applications related to java in task manager and then delete the Java.exe , Javaw.exe and Jawaws.exe from C:\windows\System32

This should solve your problem... :)

just did this and it worked

HKLM > SOFTWARE > JavaSoft > Java Runtime Environment

just manually change current version to 1.7 .

lol ... but it worked!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM