use of org.eclipse.jdt.launching.IVMInstallType in project liferay-ide by liferay.
the class LiferayTomcatRuntimeComposite method updateJREs.
protected void updateJREs() {
IJavaRuntime iJavaRuntime = getJavaRuntime();
IVMInstall currentVM = null;
if ((iJavaRuntime != null) && (iJavaRuntime.getVMInstall() != null)) {
currentVM = iJavaRuntime.getVMInstall();
} else {
currentVM = JavaRuntime.getDefaultVMInstall();
}
int currentJREIndex = -1;
// get all installed JVMs
installedJREs = new ArrayList<>();
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]);
}
}
size = installedJREs.size();
jreNames = new String[size + 1];
jreNames[0] = "<Default Workbench JRE>";
for (int i = 0; i < size; i++) {
IVMInstall vmInstall = (IVMInstall) 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 liferay-ide by liferay.
the class LiferayTomcatRuntime method getVMInstall.
@Override
public IVMInstall getVMInstall() {
if (getVMInstallTypeId() == null) {
IVMInstall vmInstall = findPortalBundledJRE(false);
if (vmInstall != null) {
setVMInstall(vmInstall);
return vmInstall;
} else {
return JavaRuntime.getDefaultVMInstall();
}
}
try {
IVMInstallType vmInstallType = JavaRuntime.getVMInstallType(getVMInstallTypeId());
IVMInstall[] vmInstalls = vmInstallType.getVMInstalls();
int size = vmInstalls.length;
String id = getVMInstallId();
for (int i = 0; i < size; i++) {
if (id.equals(vmInstalls[i].getId()))
return vmInstalls[i];
}
} catch (Exception e) {
// ignore
}
return null;
}
use of org.eclipse.jdt.launching.IVMInstallType in project eclipse.jdt.ls by eclipse.
the class JDTLanguageServerTest method testDefaultVM.
@Test
public void testDefaultVM() throws CoreException {
String oldJavaHome = prefManager.getPreferences().getJavaHome();
IVMInstall oldVm = JavaRuntime.getDefaultVMInstall();
assertNotNull(oldVm);
try {
IVMInstall vm = null;
IVMInstallType type = JavaRuntime.getVMInstallType(TestVMType.VMTYPE_ID);
IVMInstall[] installs = type.getVMInstalls();
for (IVMInstall install : installs) {
if (!install.equals(oldVm)) {
vm = install;
break;
}
}
assertNotNull(vm);
assertNotEquals(vm, oldVm);
String javaHome = new File(TestVMType.getFakeJDKsLocation(), "9").getAbsolutePath();
prefManager.getPreferences().setJavaHome(javaHome);
boolean changed = server.configureVM();
IVMInstall defaultVM = JavaRuntime.getDefaultVMInstall();
assertTrue("A VM hasn't been changed", changed);
assertEquals(vm, defaultVM);
assertNotEquals(oldVm, defaultVM);
} finally {
prefManager.getPreferences().setJavaHome(oldJavaHome);
TestVMType.setTestJREAsDefault();
}
}
use of org.eclipse.jdt.launching.IVMInstallType in project liferay-ide by liferay.
the class ProjectCoreBase method ensureDefaultVMInstallExists.
private void ensureDefaultVMInstallExists() throws CoreException {
IVMInstall vmInstall = JavaRuntime.getDefaultVMInstall();
if (vmInstall != null) {
return;
}
final IVMInstallType vmInstallType = JavaRuntime.getVMInstallType(StandardVMType.ID_STANDARD_VM_TYPE);
String id = null;
do {
id = String.valueOf(System.currentTimeMillis());
} while (vmInstallType.findVMInstall(id) != null);
VMStandin newVm = new VMStandin(vmInstallType, id);
newVm.setName("Default-VM");
String jrePath = System.getProperty("java.home");
File installLocation = new File(jrePath);
newVm.setInstallLocation(installLocation);
IVMInstall realVm = newVm.convertToRealVM();
JavaRuntime.setDefaultVMInstall(realVm, new NullProgressMonitor());
}
use of org.eclipse.jdt.launching.IVMInstallType in project webtools.servertools by eclipse.
the class GenericRuntime method getVMInstall.
/**
* @see IGenericRuntime#getVMInstall()
*/
public IVMInstall getVMInstall() {
if (getVMInstallTypeId() == null)
return JavaRuntime.getDefaultVMInstall();
try {
IVMInstallType vmInstallType = JavaRuntime.getVMInstallType(getVMInstallTypeId());
IVMInstall[] vmInstalls = vmInstallType.getVMInstalls();
String id = getVMInstallId();
for (IVMInstall vmInst : vmInstalls) {
if (id.equals(vmInst.getId()))
return vmInst;
}
} catch (Exception e) {
// ignore
}
return null;
}
Aggregations