在 Windows 64 上以 32 位模式运行 java

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/24009725/
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-14 09:41:43  来源:igfitidea点击:

Running java in 32 bit mode on windows 64

javajvm32bit-64bit

提问by lviggiani

I need to run java in 32 bit mode under windows 8.1 64 bit.

我需要在 Windows 8.1 64 位下以 32 位模式运行 java。

I have installed java 7 jre under c:\Program Files\Java\jre7(64bit JVM) and under c:\Program Files (x86)\Java\jre7(32bit JVM).

我已经在c:\Program Files\Java\jre7(64 位 JVM)和c:\Program Files (x86)\Java\jre7(32 位 JVM)下安装了 java 7 jre 。

However, if from cmd I issue java -d32 -version, I get this error:

但是,如果从 cmd 我发出java -d32 -version,我会收到此错误:

Error: This Java instance does not support a 32-bit JVM.
Please install the desired version.

Without the -d32switch it confirms its running the 64 bit JVM:

如果没有-d32开关,它会确认它正在运行 64 位 JVM:

Java(TM) SE Runtime Environment (build 1.7.0_51-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.51-b03, mixed mode)

So I opened the java control panel and added the 32bit JVM to the user installed JRE (system tab does not allow me to change anything even if running as administrator), but nothing changes.

所以我打开java控制面板并将32位JVM添加到用户安装的JRE中(即使以管理员身份运行,系统选项卡也不允许我更改任何内容),但没有任何变化。

I've read some posts of users saying that with java 7+ the -d32mode should be supported but I can't get it. Can someone help me please?

我读过一些用户的帖子,说使用 java 7+-d32应该支持该模式,但我无法理解。有人能帮助我吗?

Note:Please note that I cannot remove the 64bit JVM because I need it for other applications

注意:请注意,我无法删除 64 位 JVM,因为其他应用程序需要它

采纳答案by lviggiani

I've found another solution to that. By using launchj4I can wrap my jar into an exe and I can specify the JRE I want to use and force it to search for a 32bit JVM, set min and max version etc (see the JRE). The wrapper will automatically search installed JRE's and chose the one that meets the requirements.

我找到了另一个解决方案。通过使用launchj4,我可以将 jar 包装到一个 exe 中,我可以指定我想要使用的 JRE 并强制它搜索 32 位 JVM,设置最小和最大版本等(请参阅 JRE)。包装器将自动搜索已安装的 JRE 并选择满足要求的一个。

Also wrapping my jar into an exe is more convenient for deploying my application.

还将我的 jar 包装到 exe 中更便于部署我的应用程序。

回答by durrrr

Why don't you just install the 32-bit version of Java as well from the link below:

为什么不直接从以下链接安装 32 位版本的 Java:

Java Downloads for All Operating Systems

适用于所有操作系统的 Java 下载

回答by Mustafa sabir

You can have both 32bit and 64 bit installed on the same machine. Infact you can have multiple version of each of 32bit and 64bit installed (eg - java6 and java7). Because each JRE will be installed in different folders, it usually does not matter.

您可以在同一台机器上安装 32 位和 64 位。事实上,您可以安装 32 位和 64 位的多个版本(例如 - java6 和 java7)。因为每个 JRE 都会安装在不同的文件夹中,所以通常没有关系。

When running different versions of jre, your application will search for the Java executable using the PATH variable. So if Java 32bit is first on the PATH, you will have problems running a Java 64bit application. You can modify the path to use a certain Java version e.g. by defining a environment variable JAVA32HOME with the value C:\java\java6 (32bit) and change the command to

当运行不同版本的 jre 时,您的应用程序将使用 PATH 变量搜索 Java 可执行文件。因此,如果 Java 32 位在 PATH 上是第一个,那么在运行 Java 64 位应用程序时就会出现问题。您可以修改路径以使用某个 Java 版本,例如通过定义一个值为 C:\java\java6 (32bit) 的环境变量 JAVA32HOME 并将命令更改为

%JAVA32HOME%\bin\java ...

%JAVA32HOME%\bin\java ...

Or you can manually add the version you want to use, first in the PATH variable. Remember the first instance of java.exe found while searching your PATH will be the one that is executed.

或者您可以手动添加要使用的版本,首先在 PATH 变量中。请记住,在搜索 PATH 时找到的第一个 java.exe 实例将被执行。

回答by RealHowTo

According to this FAQ:

根据此常见问题解答

How do I select between 32 and 64-bit operation? What's the default?

The options -d32 and -d64 have been added to the Java launcher to specify whether the program is to be run in a 32 or 64-bit environment. On Solaris these correspond to the ILP32 and LP64 data models, respectively. Since Solaris has both a 32 and 64-bit J2SE implementation contained within the same installation of Java, you can specify either version. If neither -d32 nor -d64 is specified, the default is to run in a 32-bit environment. Other Java commands (javac, javadoc, etc.) will rarely need to be executed in a 64-bit environment. However, the -d32/-d64 options may be passed to these commands and then on to the Java launcher using the established -J prefix option (eg: -J-d64).
All other platforms (Windows and Linux) contain separate 32 and 64-bit installation packages. If both packages are installed on a system, you select one or the other by adding the appropriate "bin" directory to your path. For consistency, the Java implementations on Linux accept the -d64 option.

如何在 32 位和 64 位操作之间进行选择?默认是什么?

选项 -d32 和 -d64 已添加到 Java 启动器中,以指定程序是在 32 位还是 64 位环境中运行。在 Solaris 上,它们分别对应于 ILP32 和 LP64 数据模型。由于 Solaris 在同一 Java 安装中同时包含 32 位和 64 位 J2SE 实现,因此您可以指定任一版本。如果 -d32 和 -d64 均未指定,则默认为在 32 位环境中运行。其他 Java 命令(javac、javadoc 等)很少需要在 64 位环境中执行。但是,-d32/-d64 选项可以传递给这些命令,然后使用已建立的 -J 前缀选项(例如:-J-d64)传递给 Java 启动器。
所有其他平台(Windows 和 Linux)都包含单独的 32 位和 64 位安装包。如果两个软件包都安装在一个系统上,您可以通过将适当的“bin”目录添加到您的路径中来选择其中一个。为了保持一致性,Linux 上的 Java 实现接受 -d64 选项。