Java 在 Windows XP 上安装 JDK8 - advapi32.dll 错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20965564/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-13 05:36:38  来源:igfitidea点击:

installing JDK8 on Windows XP - advapi32.dll error

javadlljava-8windows-xp

提问by yashhy

I downloaded JDK8build b121 and while trying to install I'm getting the following error:

我下载了JDK8build b121,在尝试安装时出现以下错误:

the procedure entry point RegDeleteKeyExA could not be located in the dynamic link library ADVAPI32.dll

the procedure entry point RegDeleteKeyExA could not be located in the dynamic link library ADVAPI32.dll

The operating system is Windows XP, Version 2002 Service Pack 3, 32-bit.

操作系统为 Windows XP,版本 2002 Service Pack 3,32 位。

采纳答案by yashhy

This happens because Oracle dropped support for Windows XP (which doesn't have RegDeleteKeyExAused by the installer in its ADVAPI32.DLLby the way) as described in http://mail.openjdk.java.net/pipermail/openjfx-dev/2013-July/009005.html. Yet while the official support for XP has ended, the Java binaries are still (as of Java 8u20 EA b05 at least) XP-compatible - only the installer isn't...

发生这种情况是因为 Oracle 放弃了对 Windows XP 的支持(顺便说一下RegDeleteKeyExA,安装程序没有使用它ADVAPI32.DLL),如http://mail.openjdk.java.net/pipermail/openjfx-dev/2013-July/ 中所述009005.html。然而,虽然对 XP 的官方支持已经结束,但 Java 二进制文件仍然(至少从 Java 8u20 EA b05 开始)与 XP 兼容——只有安装程序不是......

Because of that, the solution is actually quite easy:

因此,解决方案实际上很简单:

  1. get 7-Zip (or any other good unpacker), unpack the distribution .exe manually, it has one .zip file inside of it (tools.zip), extract it too,

  2. use unpack200from JDK8 to unpack all .pack files to .jar files (older unpacks won't work properly); JAVA_HOMEenvironment variable should be set to your Java unpack root, e.g. "C:\Program Files\Java\jdk8" - you can specify it implicitly by e.g.

    SET JAVA_HOME=C:\Program Files\Java\jdk8
    
    • Unpack all files with a single command (in batch file):

      FOR /R %%f IN (*.pack) DO "%JAVA_HOME%\bin\unpack200.exe" -r -v "%%f" "%%~pf%%~nf.jar"
      
    • Unpack all files with a single command (command line from JRE root):

      FOR /R %f IN (*.pack) DO "bin\unpack200.exe" -r -v "%f" "%~pf%~nf.jar"
      
    • Unpack by manually locating the files and unpacking them one-by-one:

      %JAVA_HOME%\bin\unpack200 -r packname.pack packname.jar
      

    where packnameis for example rt

  3. point the tool you want to use (e.g. Netbeans) to the %JAVA_HOME%and you're good to go.

  1. 获取 7-Zip(或任何其他好的解包器),手动解压发行版 .exe,其中包含一个 .zip 文件(tools.zip),也将其解压缩,

  2. 使用unpack200JDK8 将所有 .pack 文件解压为 .jar 文件(较旧的解包将无法正常工作);JAVA_HOME环境变量应设置为您的 Java 解包根目录,例如“C:\Program Files\Java\jdk8” - 您可以通过例如隐式指定它

    SET JAVA_HOME=C:\Program Files\Java\jdk8
    
    • 使用单个命令解压所有文件(在批处理文件中):

      FOR /R %%f IN (*.pack) DO "%JAVA_HOME%\bin\unpack200.exe" -r -v "%%f" "%%~pf%%~nf.jar"
      
    • 使用单个命令(来自 JRE 根目录的命令行)解压所有文件:

      FOR /R %f IN (*.pack) DO "bin\unpack200.exe" -r -v "%f" "%~pf%~nf.jar"
      
    • 通过手动定位文件并一一解包来解包:

      %JAVA_HOME%\bin\unpack200 -r packname.pack packname.jar
      

    packname例如在哪里rt

  3. 将您要使用的工具(例如 Netbeans)指向%JAVA_HOME%,您就可以开始使用了。

Note: you probably shouldn't do this just to use Java 8 in your web browser or for any similar reason (installing JRE 8 comes to mind); security flaws in early updates of major Java version releases are (mind me) legendary, and adding to that no real support for neither XP nor Java 8 on XP only makes matters much worse. Not to mention you usually don'tneed Java in your browser (see e.g. http://nakedsecurity.sophos.com/2013/01/15/disable-java-browsers-homeland-security/- the topic is already covered on many pages, just Google it if you require further info). In any case, AFAIK the only thing required to apply this procedure to JRE is to change some of the paths specified above from \bin\to \lib\(the file placement in installer directory tree is a bit different) - yet I stronglyadvise against doing it.

注意:您可能不应该仅仅为了在您的 Web 浏览器中使用 Java 8 或出于任何类似原因(想到安装 JRE 8)而这样做;主要 Java 版本发布的早期更新中的安全漏洞是(请注意我)传奇,而且在 XP 上对 XP 和 Java 8 都没有真正的支持只会使情况变得更糟。更何况你平时并不需要的Java的浏览器(例如参见http://nakedsecurity.sophos.com/2013/01/15/disable-java-browsers-homeland-security/-该主题已经涵盖在许多页面,如果您需要更多信息,只需谷歌一下)。在任何情况下,AFAIK 将此过程应用于 JRE 的唯一要求是将上面指定的一些路径从\bin\更改为\lib\(安装程序目录树中的文件位置有点不同) - 但我强烈建议不要这样做。

See also: How can I get the latest JRE / JDK as a zip file rather than EXE or MSI installer?, JRE 1.7 - java version - returns: java/lang/NoClassDefFoundError: java/lang/Object

另请参阅:如何将最新的 JRE/JDK 作为 zip 文件而不是 EXE 或 MSI 安装程序获取?, JRE 1.7 - java 版本 - 返回:java/lang/NoClassDefFoundError: java/lang/Object

回答by user3467974

With JRE 8 on XP there is another way - to use MSI to deploy package.

对于 XP 上的 JRE 8,还有另一种方法 - 使用 MSI 来部署包。

  • Install JRE 8 x86 on a PC with supported OS
  • Copy c:\Users[USER]\AppData\LocalLow\Sun\Java\jre1.8.0\jre1.8.0.msi and Data1.cab to XP PC and run jre1.8.0.msi
  • 在具有受支持操作系统的 PC 上安装 JRE 8 x86
  • 将 c:\Users[USER]\AppData\LocalLow\Sun\Java\jre1.8.0\jre1.8.0.msi 和 Data1.cab 复制到 XP PC 并运行 jre1.8.0.msi

or (silent way, usable in batch file etc..)

或(静默方式,可用于批处理文件等。)

for %%I in ("*.msi") do if exist "%%I" msiexec.exe /i %%I /qn EULA=0 SKIPLICENSE=1 PROG=0 ENDDIALOG=0

回答by user3467974

There is also an alternate solution for those who aren't afraid of using hex editors (e.g. XVI32) [thanks to Trevorfor this]: in the unpacked1installer executable (jdk-8uXX-windows-i586.exein case of JDK) simply replace all occurrences of RegDeleteKeyExA(the name of API found in "new" ADVAPI32.DLL) with RegDeleteKeyA(legacy API name), followed by two hex '00's (to preserve padding/segmentation boundaries). The installer will complain about unsupported Windows version, but will work nevertheless.

对于那些不害怕使用十六进制编辑器(例如 XVI32)的人来说,还有一个替代解决方案 [感谢Trevor]:在解压的1 个安装程序可执行文件(jdk-8uXX-windows-i586.exe在 JDK 的情况下)中,只需替换所有出现的RegDeleteKeyExA(名称在 "new" 中找到的 APIADVAPI32.DLL带有RegDeleteKeyA(旧 API 名称),后跟两个十六进制“00”(以保留填充/分段边界)。安装程序会抱怨不支持的 Windows 版本,但仍然可以工作。

For reference, the raw hex strings will be:

作为参考,原始十六进制字符串将是:

52 65 67 44 65 6C 65 74 65 4B 65 79 45 78 41

replaced with

替换为

52 65 67 44 65 6C 65 74 65 4B 65 79 41 00 00

Note: this procedure applies to both offline (standalone) and online (downloader) package.

注意:此过程适用于离线(独立)和在线(下载器)包。

1: some newer installer versions are packed with UPX- you'd need to unpack them first, otherwise you simply won't be able to find the hex string required

1: 一些较新的安装程序版本包含UPX- 您需要先解压缩它们,否则您将无法找到所需的十六进制字符串

回答by kevingreen

Oracle has announced fix for Windows XP installation error

Oracle 已宣布修复 Windows XP 安装错误

Oracle has decided to fix Windows XP installation. As of the JRE 8u25 release in 10/15/2014 the code of the installer has been changes so that installation on Windows XP is again possible.

Oracle 已决定修复 Windows XP 安装。从 2014 年 10 月 15 日发布的 JRE 8u25 开始,安装程序的代码已经更改,以便再次可以在 Windows XP 上进行安装。

However, this does not mean that Oracle is continuing to support Windows XP. They make no guarantee about current and future releases of JRE8 being compatible with Windows XP. It looks like it's a run at your own risk kind of thing.

但是,这并不意味着 Oracle 将继续支持 Windows XP。他们不保证 JRE8 的当前和未来版本与 Windows XP 兼容。看起来这是一种风险自担的事情。

See the Oracle blog post here.

请参阅此处Oracle 博客文章。

You can get the latest JRE8right off the Oracle downloads site.

您可以直接从 Oracle 下载站点获取最新的 JRE8