How to identify if installed JDK is 64 or 32 bit

As you all know, all the modern CPU models are all 64-bit. The software we use on a such machine could be 32-bit or 64-bit. In a 32-bit operating system (OS) you can only install 32-bit software, so you can only have 32-bit JDK. In a 64-bit OS you can install 32-bit and/or 64-bit software.
There are still a few platforms that are only compatible with 32-bit JDK, like the HP OpenCall Convergent Communication Platform that I am working with. HP has almost ready the 64-bit release, but this is another story.

There are times that you login to a server with an already installed JDK and you have to know if this is a 32-bit or a 64-bit JDK.
My recommended procedure to find it out is to run in a CLI this command:
$> java -d64 -version

You can run this command on 32-bit and 64-bit JDKs, but it produces different result, where you can understand which kind of JDK you are using.
Here is a sample output:

32-bit JDK

$> java -d64 -version
Running a 64-bit JVM is not supported on this platform

64-bit JDK

$> java -d64 -version
java version "1.6.0_31"
Java(TM) SE Runtime Environment (build 1.6.0_31-b05) 
Oracle JRockit(R) (build R28.2.3-13-149708-1.6.0_31-20120327-1523-linux-x86_64, compiled mode)

When you running it on a 32-bit JDK, the command is not supported, so you get an error message. While when running it on 64-bit JDK you get the information of the installed JDK.
This method works both with HotSpot and JRockit JVMs, but it is only supported on Linux and Solaris (thanks to Petros catch).

Regards,
Adrianos Dadis.

Democracy Requires Free Software

Advertisements

About Adrianos Dadis

Building Big Data & Streaming processing solutions in telcos business domain. Interested in distributed systems and enterprise integration.
This entry was posted in Administration, Java, Software Development and tagged , , , , , . Bookmark the permalink.

2 Responses to How to identify if installed JDK is 64 or 32 bit

  1. Hi Adrianos,

    Is the recommended procedure only for Linux versions of java as I run the following on Windows XP 64bit and I get the following output.

    Kind regards,

    Petros

    C:\>java -version
    java version “1.6.0_24”
    Java(TM) SE Runtime Environment (build 1.6.0_24-b07)
    Java HotSpot(TM) 64-Bit Server VM (build 19.1-b02, mixed mode)

    C:\>java -d64 -version
    Unrecognized option: -d64
    Could not create the Java virtual machine.

    • Adrianos Dadis says:

      I have to say that I have a few years to use a Windows server and I do not remember any result.
      I just read the manual (I cannot easily access a Windows server, because not having any) and you are right. This parameter is not compatible with Windows.
      Well done Petros!

Post your thought

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s