use of org.eclipse.jdt.launching.IVMInstallType in project liferay-ide by liferay.
the class PortalRuntimeComposite method updateJREs.
protected void updateJREs() {
PortalRuntime portalRuntime = getPortalRuntime();
IVMInstall currentVM = null;
if (portalRuntime != null && portalRuntime.getVMInstall() != null) {
currentVM = portalRuntime.getVMInstall();
} else {
currentVM = JavaRuntime.getDefaultVMInstall();
}
int currentJREIndex = -1;
// get all installed JVMs
installedJREs = new ArrayList<IVMInstall>();
IVMInstallType[] vmInstallTypes = JavaRuntime.getVMInstallTypes();
int size = vmInstallTypes.length;
for (int i = 0; i < size; i++) {
IVMInstall[] vmInstalls = vmInstallTypes[i].getVMInstalls();
int size2 = vmInstalls.length;
for (int j = 0; j < size2; j++) {
installedJREs.add(vmInstalls[j]);
}
}
// get names
size = installedJREs.size();
jreNames = new String[size + 1];
jreNames[0] = Msgs.defaultWorkbenchJRE;
for (int i = 0; i < size; i++) {
IVMInstall vmInstall = installedJREs.get(i);
jreNames[i + 1] = vmInstall.getName();
if (vmInstall.equals(currentVM)) {
currentJREIndex = i + 1;
}
}
if (jreCombo != null) {
jreCombo.setItems(jreNames);
jreCombo.select(currentJREIndex);
}
}
use of org.eclipse.jdt.launching.IVMInstallType in project eclipse.jdt.ls by eclipse.
the class JDTLanguageServer method configureVM.
public boolean configureVM() throws CoreException {
String javaHome = preferenceManager.getPreferences().getJavaHome();
if (javaHome != null) {
File jvmHome = new File(javaHome);
if (jvmHome.isDirectory()) {
IVMInstall defaultVM = JavaRuntime.getDefaultVMInstall();
File location = defaultVM.getInstallLocation();
if (!location.equals(jvmHome)) {
IVMInstall vm = findVM(jvmHome);
if (vm == null) {
IVMInstallType installType = JavaRuntime.getVMInstallType(StandardVMType.ID_STANDARD_VM_TYPE);
long unique = System.currentTimeMillis();
while (installType.findVMInstall(String.valueOf(unique)) != null) {
unique++;
}
String vmId = String.valueOf(unique);
VMStandin vmStandin = new VMStandin(installType, vmId);
String name = StringUtils.defaultIfBlank(jvmHome.getName(), "JRE");
vmStandin.setName(name);
vmStandin.setInstallLocation(jvmHome);
vm = vmStandin.convertToRealVM();
}
JavaRuntime.setDefaultVMInstall(vm, new NullProgressMonitor());
JDTUtils.setCompatibleVMs(vm.getId());
return true;
}
}
}
return false;
}
use of org.eclipse.jdt.launching.IVMInstallType in project eclipse.jdt.ls by eclipse.
the class TestVMInstall method setTestJREAsDefault.
public static void setTestJREAsDefault() throws CoreException {
IVMInstallType vmInstallType = JavaRuntime.getVMInstallType(VMTYPE_ID);
IVMInstall testVMInstall = vmInstallType.findVMInstall("1.8");
if (!testVMInstall.equals(JavaRuntime.getDefaultVMInstall())) {
// set the 1.8 test JRE as the new default JRE
JavaRuntime.setDefaultVMInstall(testVMInstall, new NullProgressMonitor());
}
JDTUtils.setCompatibleVMs(VMTYPE_ID);
}
use of org.eclipse.jdt.launching.IVMInstallType in project mdw-designer by CenturyLinkCloud.
the class ProjectConfigurator method getJreContainerClasspathEntry.
private IClasspathEntry getJreContainerClasspathEntry(String desiredVersion) {
for (IVMInstallType installType : JavaRuntime.getVMInstallTypes()) {
if (installType instanceof AbstractVMInstallType) {
AbstractVMInstallType install = (AbstractVMInstallType) installType;
for (IVMInstall vmInstall : install.getVMInstalls()) {
if (vmInstall instanceof IVMInstall2) {
IVMInstall2 vmInstall2 = (IVMInstall2) vmInstall;
if (vmInstall2.getJavaVersion() != null && vmInstall2.getJavaVersion().startsWith(desiredVersion)) {
IPath containerPath = new Path(JavaRuntime.JRE_CONTAINER);
IPath vmPath = containerPath.append(vmInstall.getVMInstallType().getId()).append(vmInstall.getName());
return JavaCore.newContainerEntry(vmPath);
}
}
}
}
}
return null;
}
Aggregations