Java Is Windows isWindows64JREAvailable()

Here you can find the source of isWindows64JREAvailable()

Description

is Windows JRE Available

License

Open Source License

Declaration

public static boolean isWindows64JREAvailable() 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.io.File;

import java.io.IOException;

public class Main {
    public static boolean isWindows64JREAvailable() {

        try {//from  w w  w .j a  v a 2  s .c o  m
            String javaHome = new File(System.getProperty("java.home")).getCanonicalPath();

            try {
                if (System.getProperty("os.name").startsWith("Windows")) {
                    int dataModel = Integer.parseInt(System.getProperty("sun.arch.data.model"));

                    if (dataModel != 64) {
                        int idx = javaHome.indexOf(" (x86)");
                        if (idx > -1) {
                            // Looks like we have a 32bit Java version installed on 64 bit Windows
                            String programFiles = javaHome.substring(0, idx);
                            File j = new File(programFiles, "Java");
                            if (j.exists()) {
                                // We may have a 64 bit version of Java installed.
                                String[] jres = j.list();
                                for (int i = 0; i < jres.length; i++) {

                                    File h = new File(j, jres[i]);
                                    File exe = new File(h, "bin\\java.exe");
                                    if (exe.exists()) {
                                        // Found a 64bit version of java
                                        return true;
                                    }
                                }
                            }
                        }
                    }
                }
            } catch (NumberFormatException ex) {
            }

            return false;
        } catch (IOException ex) {
            return false;
        }
    }
}

Related

  1. isWindows()
  2. isWindows()
  3. isWindows()
  4. isWindows()
  5. isWindows()
  6. isWindowsAdministrator()
  7. isWindowsCygwin()
  8. isWindowsFileSep()
  9. isWindowsFileSystem()