简体   繁体   English

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

[英]Running java in 32 bit mode on windows 64

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 -d32 switch 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 -d32 mode should be supported but I can't get it.我读过一些用户的帖子,说使用 java 7+ 应该支持-d32模式,但我无法理解。

Note: Please note that I cannot remove the 64bit JVM because I need it for other applications注意:请注意,我无法删除 64 位 JVM,因为其他应用程序需要它

According to this FAQ :根据此常见问题解答

How do I select between 32 and 64-bit operation?如何在 32 位和 64 位操作之间进行选择? 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.选项 -d32 和 -d64 已添加到 Java 启动器中,以指定程序是在 32 位还是 64 位环境中运行。 On Solaris these correspond to the ILP32 and LP64 data models, respectively.在 Solaris 上,它们分别对应于 ILP32 和 LP64 数据模型。 Since Solaris has both a 32 and 64-bit J2SE implementation contained within the same installation of Java, you can specify either version.由于 Solaris 在同一 Java 安装中同时包含 32 位和 64 位 J2SE 实现,因此您可以指定任一版本。 If neither -d32 nor -d64 is specified, the default is to run in a 32-bit environment.如果 -d32 和 -d64 均未指定,则默认为在 32 位环境中运行。 Other Java commands (javac, javadoc, etc.) will rarely need to be executed in a 64-bit environment.其他 Java 命令(javac、javadoc 等)很少需要在 64 位环境中执行。 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).但是,-d32/-d64 选项可以传递给这些命令,然后使用已建立的 -J 前缀选项(例如:-J-d64)传递给 Java 启动器。
All other platforms (Windows and Linux) contain separate 32 and 64-bit installation packages.所有其他平台(Windows 和 Linux)都包含单独的 32 位和 64 位安装包。 If both packages are installed on a system, you select one or the other by adding the appropriate "bin" directory to your path.如果两个软件包都安装在一个系统上,您可以通过将适当的“bin”目录添加到您的路径中来选择其中一个。 For consistency, the Java implementations on Linux accept the -d64 option.为了保持一致性,Linux 上的 Java 实现接受 -d64 选项。

I've found another solution to that.我找到了另一个解决方案。 By using launchj4 I 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).通过使用launchj4,我可以将 jar 包装到一个 exe 中,我可以指定我想要使用的 JRE 并强制它搜索 32 位 JVM,设置最小和最大版本等(请参阅 JRE)。 The wrapper will automatically search installed JRE's and chose the one that meets the requirements.包装器将自动搜索已安装的 JRE 并选择满足要求的一个。

Also wrapping my jar into an exe is more convenient for deploying my application.还将我的 jar 包装到 exe 中更便于部署我的应用程序。

You can have both 32bit and 64 bit installed on the same machine.您可以在同一台机器上安装 32 位和 64 位。 Infact you can have multiple version of each of 32bit and 64bit installed (eg - java6 and java7).事实上,您可以安装 32 位和 64 位的多个版本(例如 - java6 和 java7)。 Because each JRE will be installed in different folders, it usually does not matter.因为每个 JRE 都会安装在不同的文件夹中,所以通常没有关系。

When running different versions of jre, your application will search for the Java executable using the PATH variable.当运行不同版本的 jre 时,您的应用程序将使用 PATH 变量搜索 Java 可执行文件。 So if Java 32bit is first on the PATH, you will have problems running a Java 64bit application.因此,如果 Java 32 位在 PATH 上是第一个,那么在运行 Java 64 位应用程序时就会出现问题。 You can modify the path to use a certain Java version eg by defining a environment variable JAVA32HOME with the value C:\\java\\java6 (32bit) and change the command to您可以修改路径以使用某个 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.或者您可以手动添加要使用的版本,首先在 PATH 变量中。 Remember the first instance of java.exe found while searching your PATH will be the one that is executed.请记住,在搜索 PATH 时找到的第一个 java.exe 实例将被执行。

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 下载

Consider going to your settings , choosing your active profile then click on advanced settings , now on the menu that pops up and choose the version you would like to work with .考虑进入您的设置,选择您的活动配置文件,然后单击高级设置,现在在弹出的菜单上选择您想要使用的版本。 Once everything is configured use the terminal to verify the usage of the right version.配置完所有内容后,使用终端来验证正确版本的使用情况。 Now incaqse thus pdate-alternatives --config java.现在 incaqse 因此pdate-alternatives --config java. through the terminal and update any values by selecting the version you like and pressing down on the enter key on the output you get通过终端并通过选择您喜欢的版本并按下您获得的输出上的输入键来更新任何值

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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