java -d64 -jar,启动Java时-d32和-d64的用法

I read below excerpt from 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.

Now to test this, I logged in into my 64 bit Ubuntu guest OS and installed 64 bit JDK version - Linux x64 165.24 MB jdk-8u45-linux-x64.tar.gz.

After installing the JDK, when I run my java program using -d64 then everything is as expected because it is in fact a 64 bit installation but when I use -d32 then I get error saying Error - This Java instance does not support 32 bit JVM.

Error is understandable to me, but what confuses me is this line (as in above quoted para) "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."

As per this line, my understanding is that when launching Java of 64 bit version, -d32 can be used to launch it in 32 bit mode.

Questions:

Is my understanding correct? And if it is correct, then I am getting error?

If my understanding is not true, then why do I need these command-line arguments, because when I will launch Java using java then whichever installation (32 bit or 64 bit JDK) is in my PATH will be launched.

解决方案

The citation you made:

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.

is valid only for the Solaris operating system.

Later in the JDK's FAQ, we can read:

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.

So to answer your second question, in Windows and in Linux, theses flags are useless and the 32/64 bit selection is done by running the corresponding JVM installation.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值