Search in sources :

Example 1 with JdkBundle

use of com.intellij.util.JdkBundle in project intellij-community by JetBrains.

the class SystemHealthMonitor method checkJvm.

private void checkJvm() {
    if (StringUtil.endsWithIgnoreCase(System.getProperty("java.version", ""), "-ea")) {
        showNotification(new KeyHyperlinkAdapter("unsupported.jvm.ea.message"));
    }
    JdkBundle bundle = JdkBundle.createBoot();
    if (bundle != null && !bundle.isBundled()) {
        Version version = bundle.getVersion();
        Integer updateNumber = bundle.getUpdateNumber();
        if (version != null && updateNumber != null && updateNumber < 112) {
            final String bundleVersion = version.toCompactString() + "u" + updateNumber;
            boolean showSwitchOption = false;
            final File bundledJDKAbsoluteLocation = JdkBundle.getBundledJDKAbsoluteLocation();
            if (bundledJDKAbsoluteLocation.exists() && bundle.getBitness() == Bitness.x64) {
                if (SystemInfo.isMacIntel64) {
                    showSwitchOption = true;
                } else if (SystemInfo.isWindows || SystemInfo.isLinux) {
                    JdkBundle bundledJdk = JdkBundle.createBundle(bundledJDKAbsoluteLocation, false, false);
                    if (bundledJdk != null && bundledJdk.getVersion() != null) {
                        // Version of bundled jdk is available, so the jdk is compatible with underlying OS
                        showSwitchOption = true;
                    }
                }
            }
            if (showSwitchOption) {
                showNotification(new KeyHyperlinkAdapter("outdated.jvm.version.message1") {

                    @Override
                    protected void hyperlinkActivated(HyperlinkEvent e) {
                        String url = e.getDescription();
                        if ("ack".equals(url)) {
                            myProperties.setValue(getIgnoreKey(), "true");
                        } else if ("switch".equals(url)) {
                            ActionManager.getInstance().getAction(SWITCH_JDK_ACTION).actionPerformed(null);
                        } else {
                            BrowserUtil.browse(url);
                        }
                    }
                }, bundleVersion, LATEST_JDK_RELEASE);
            } else {
                showNotification(new KeyHyperlinkAdapter("outdated.jvm.version.message2"), bundleVersion, LATEST_JDK_RELEASE);
            }
        }
    }
}
Also used : HyperlinkEvent(javax.swing.event.HyperlinkEvent) Version(com.intellij.openapi.util.Version) File(java.io.File) JdkBundle(com.intellij.util.JdkBundle)

Example 2 with JdkBundle

use of com.intellij.util.JdkBundle in project intellij-community by JetBrains.

the class SwitchBootJdkAction method findJdkPaths.

@NotNull
public static JdkBundleList findJdkPaths() {
    JdkBundle bootJdk = JdkBundle.createBoot();
    JdkBundleList jdkBundleList = new JdkBundleList();
    if (bootJdk != null) {
        jdkBundleList.addBundle(bootJdk, true);
    }
    if (new File(PathManager.getHomePath() + File.separator + bundledJdkFile).exists()) {
        JdkBundle bundledJdk = JdkBundle.createBundle(bundledJdkFile, false, true);
        if (bundledJdk != null) {
            jdkBundleList.addBundle(bundledJdk, true);
        }
    }
    if (SystemInfo.isMac) {
        jdkBundleList.addBundlesFromLocation(STANDARD_JDK_LOCATION_ON_MAC_OS_X, JDK8_VERSION, null);
    } else if (SystemInfo.isLinux) {
        for (String location : STANDARD_JVM_LOCATIONS_ON_LINUX) {
            jdkBundleList.addBundlesFromLocation(location, JDK8_VERSION, null);
        }
    } else if (SystemInfo.isWindows) {
        for (File root : File.listRoots()) {
            if (SystemInfo.is32Bit) {
                jdkBundleList.addBundlesFromLocation(new File(root, STANDARD_JVM_X86_LOCATIONS_ON_WINDOWS).getAbsolutePath(), JDK8_VERSION, null);
            } else {
                jdkBundleList.addBundlesFromLocation(new File(root, STANDARD_JVM_X64_LOCATIONS_ON_WINDOWS).getAbsolutePath(), JDK8_VERSION, null);
            }
        }
    }
    return jdkBundleList;
}
Also used : JdkBundleList(com.intellij.util.JdkBundleList) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File) JdkBundle(com.intellij.util.JdkBundle) NotNull(org.jetbrains.annotations.NotNull)

Example 3 with JdkBundle

use of com.intellij.util.JdkBundle in project intellij-community by JetBrains.

the class GuiTestUtil method getBundledJdLocation.

public static String getBundledJdLocation() {
    ArrayList<JdkBundle> bundleList = SwitchBootJdkAction.findJdkPaths().toArrayList();
    //we believe that Idea has at least one bundled jdk
    JdkBundle jdkBundle = bundleList.get(0);
    String homeSubPath = SystemInfo.isMac ? "/Contents/Home" : "";
    return jdkBundle.getLocation().getAbsolutePath() + homeSubPath;
}
Also used : JdkBundle(com.intellij.util.JdkBundle)

Aggregations

JdkBundle (com.intellij.util.JdkBundle)3 File (java.io.File)2 Version (com.intellij.openapi.util.Version)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 JdkBundleList (com.intellij.util.JdkBundleList)1 HyperlinkEvent (javax.swing.event.HyperlinkEvent)1 NotNull (org.jetbrains.annotations.NotNull)1