Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Will a 64 bit JVM run in 64 bit mode when no option like -d32 or -d64 is specified

Tags:

java

jvm

I have installed a 64 bit Java on a 64 bit Centos machine. My query is that if I dont specify the -d64 option will the JVM run in 32 bit mode even if there is no 32 bit JVM installed ?

Also I was a bit curious if we can use the -d64 option with "javac". If yes, then what does it imply or where could it be used? I came across this when reading this article.

Thanks

like image 853
Twaha Mehmood Avatar asked May 22 '12 06:05

Twaha Mehmood


People also ask

What is 64 bit JVM?

The 64-bit JVM is especially useful for Java applications with large heaps, such as those that use more than 100 GB of memory as a maximum. Because the size of the OOP (Ordinary Object Pointer) has increased from 32 to 64 bits, the same Java application will use more memory in the 64-bit JVM than in the 32-bit JVM.

Is there a 64 bit Java?

Java is available on Microsoft Windows in 64 and 32 bit versions, allowing users to get the appropriate version for their system. Users can even run both side-by-side for 64 bit operating systems.


2 Answers

The selection of the data model (bits) for the JRE is to constrain the operation of the application to only run in one mode. The java byte code is designed to work in both data models, so for the 100% pure java applications, will work according the behavior and benefits of each architecture.

But, if your application use native libs that work only in one mode, then the application will fail under the not supported one. For that, you must explicitly indicate in which mode it should run.

When you set -d32 or -d64 the JRE will not start your application if it can't run in the selected mode.

like image 149
Daniel De León Avatar answered Oct 16 '22 07:10

Daniel De León


From the Oracle document you linked to:

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.

(emphasis mine)

So, according to the document you linked to, the default is to run in a 32-bit JRE, and it is possible to run javac in a 64-bit JRE by passing -J-d64 rather than simply -d64.

However, note that this document also says that it applies to Java 1.4, and says nothing about more recent versions of Java.

like image 21
Adam Mihalcin Avatar answered Oct 16 '22 06:10

Adam Mihalcin