Ankit
Ankit

Reputation: 639

How do I make 32 bit or 64 bit application?

While making programs, how do I make sure that a particular application is a 64 bit application or a 32 bit application.

Is it possible to hard-code that the app would be 64 bit or 32 bit respectively and if possible would it be necessary for the 64 bit app to take more memory than usual 32 bit app?

I am aware about the memory limitation with 32 bit applications/hardware.

Upvotes: 0

Views: 1882

Answers (5)

Dhanushka Perumbuli
Dhanushka Perumbuli

Reputation: 78

After creating java application, build and get the final .jar file (If that application include 3rd party jars, get that jar files also).

  • Then Use exe4j application and you can easily create your own .exe file with x64 or x32

  • You can download exe4j from this link.

Upvotes: 0

Peter Lawrey
Peter Lawrey

Reputation: 533492

There is one byte code regardless of whether it will be used for 32-bit or 64-bit.

This means you can use libraries which were compiled on 32-bit machines before there was any 64-bit JVM, on a 64-bit JVM.

64-bit JVMs can use more memory, but not as much as you might think as modern 64-bit JVM use Compressed Oops so that you can use 32-bit references for up to 32 GB of heap. (you can use more off heap memory as well)

Many 32-bit JVM on 32-bit OSes are limited to 1.2 to 1.5 GB of memory. On 64-bit OS this limit might be 2.5 to 3.5 GB depending on the OS. A 64-bit JVM on a 64-bit OS is practically limited to around 1 TB of memory but this limit could be lifted in future (and depends on the OS)

The only difference you can have is if you use a JNI. A JNI shared library is dependant either a 32-bit or 64-bit library and you might only have one (in which case you ca only load it on a JVM of the same bit-ness) or it might behave differently.

Upvotes: 2

Adel Boutros
Adel Boutros

Reputation: 10285

Java is platform independent. Thus, you shouldn't bother about it. The only difference between 32 and 64 is in the jdk used.

If you use a 64-bit jdk, your app is 64-bit compatible

If you use a 32-bit jdk, your app is 32-bit compatible

if i compile a program on 32 bit JDK and run it on 64bit JVM will it work?

Yes it will because you are not actually compiling it, you are only creating a bytecode.

When the JVM will load your classes, it is at that time that it checks wether the jdk is 64-bit or 32-bit and makes your jvm a 64-bit or 32-bit respectively.

Upvotes: 4

npe
npe

Reputation: 15699

There is no such thing as 32 bit / 64 bit java programs.

It's the JVM itself is developed on different architectures, but the Java specification is constatnt, and does not change with the underlying hardware.

Upvotes: 0

Rosdi Kasim
Rosdi Kasim

Reputation: 25966

Java bytecode is platform independent. Unless you start calling JNI or something like that then you should not worry.

You can tell the JVM whether to run in 32bit or 64bit mode.

Upvotes: 1

Related Questions