Programming Tips - Java: See if I am running on a 32- or 64- bit system

Date: 2016sep15 Update: 2025sep24 Language: Java Q. Java: See if I am running on a 32- or 64- bit system A. Here is a full example that shows how to do it:
class Demo { // Helper static String getArch() { return System.getProperty("os.arch"); } static boolean is32bit() { // There is also "x86_64" which is 64-bit return getArch().equalsIgnoreCase("x86"); } static boolean is64bit() { // Finds "amd64" or "x86_64" return getArch().contains("64"); } public static final void main(String []args) { System.out.println("arch=" + getArch()); System.out.println("is 32 bit=" + is32bit()); System.out.println("is 64 bit=" + is64bit()); } }
Output (for me):
arch=amd64 is 32 bit=false is 64 bit=true