mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
consider java.home on any platform
This commit is contained in:
@@ -21,6 +21,8 @@ import com.intellij.openapi.projectRoots.JavaSdkVersion;
|
||||
import com.intellij.openapi.projectRoots.JdkUtil;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.SystemProperties;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
@@ -71,12 +73,22 @@ public abstract class JavaHomeFinder {
|
||||
}
|
||||
}
|
||||
|
||||
protected static File getJavaHome() {
|
||||
String property = SystemProperties.getJavaHome();
|
||||
if (property == null)
|
||||
return null;
|
||||
|
||||
File javaHome = new File(property).getParentFile();//actually java.home points to to jre home
|
||||
return javaHome == null || !javaHome.isDirectory() ? null : javaHome;
|
||||
}
|
||||
|
||||
protected static class DefaultFinder extends JavaHomeFinder {
|
||||
|
||||
private final String[] myPaths;
|
||||
|
||||
protected DefaultFinder(String... paths) {
|
||||
myPaths = paths;
|
||||
File javaHome = getJavaHome();
|
||||
myPaths = javaHome == null ? paths : ArrayUtil.prepend(javaHome.getAbsolutePath(), paths);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -29,14 +29,9 @@ class WindowsJavaFinder extends JavaHomeFinder {
|
||||
@NotNull
|
||||
@Override
|
||||
protected List<String> findExistingJdks() {
|
||||
String property = System.getProperty("java.home");
|
||||
if (property == null)
|
||||
return Collections.emptyList();
|
||||
File javaHome = getJavaHome();
|
||||
if (javaHome == null) return Collections.emptyList();
|
||||
|
||||
File javaHome = new File(property).getParentFile();//actually java.home points to to jre home
|
||||
if (javaHome == null || !javaHome.isDirectory() || javaHome.getParentFile() == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
ArrayList<String> result = new ArrayList<>();
|
||||
File javasFolder = javaHome.getParentFile();
|
||||
scanFolder(javasFolder, result);
|
||||
|
||||
Reference in New Issue
Block a user