Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Usage of -d32 and -d64 while launching Java

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:

  1. Is my understanding correct? And if it is correct, then I am getting error?
  2. 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.
like image 227
hagrawal Avatar asked Jun 26 '15 17:06

hagrawal


People also ask

What is while and do while loop in Java?

Java do-while loop is used to execute a block of statements continuously until the given condition is true. The do-while loop in Java is similar to while loop except that the condition is checked after the statements are executed, so do while loop guarantees the loop execution at least once.

Can we use while and for loop together in Java?

A "for loop" is a specialization of a "while" loop (or, for that matter, a "do/while" loop). You can do everything in a while loop that you can in a for loop. You can also nest loops, one inside another.

What is the use of while in Java?

While loop in Java comes into use when we need to repeatedly execute a block of statements. The while loop is considered as a repeating if statement. If the number of iterations is not fixed, it is recommended to use the while loop.

What is difference between while loop and for loop?

Both for loop and while loop is used to execute the statements repeatedly while the program runs. The major difference between for loop and the while loop is that for loop is used when the number of iterations is known, whereas execution is done in the while loop until the statement in the program is proved wrong.


1 Answers

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.

like image 162
Ortomala Lokni Avatar answered Oct 17 '22 05:10

Ortomala Lokni