启动时使用 -d32 和 -d64 Java

Usage of -d32 and -d64 while launching Java

我阅读了以下摘自 JDK FAQ's

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.

现在为了测试这个,我登录到我的 64 位 Ubuntu 来宾 OS 并安装了 64 位 JDK 版本 - Linux x64 165.24 MB jdk-8u45-linux-x64.tar.gz.

安装 JDK 后,当我 运行 我的 java 程序使用 -d64 时,一切都如预期的那样,因为它实际上是 64 位安装,但是当我使用 -d32 然后我得到错误说 Error - This Java instance does not support 32 bit JVM.

错误对我来说是可以理解的,但令我困惑的是这一行(如上面引用的段落)"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."
根据这一行,我的理解是,当启动 64 位版本的 Java 时,-d32 可用于以 32 位模式启动它。

问题:

  1. 我的理解对吗?如果它是正确的,那么我就会出错?
  2. 如果我的理解不正确,那我为什么需要这些命令行参数,因为当我使用 java 启动 Java 时,无论安装(32 位还是 64 位 JDK) 在我的 PATH 中将被启动。

您引用的内容:

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.

仅对 Solaris 操作系统有效。

稍后在JDK's FAQ,我们可以阅读:

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.

所以回答你的第二个问题,在 Windows 和 Linux 中,这些标志是无用的,32/64 位选择是由 运行 相应的 JVM 安装完成的。