How to check if Java is 64-bit?

To check if Java is 64-bit, run this command: java -d64 -version.

Open the Terminal or Command Prompt and run:

java -d64 -version

If it is not a 64-bit Java, you will see this message:

Error: This Java instance does not support a 64-bit JVM.
Please install the desired version.