Hi
this is not a question. It took me quit a while to figure this out, so i thougth this could be useful for someone else...
Plugin dependency: org.eclipse.jdt.launching
void installJre(String name, String path) throws CoreException, IOException {
File installLocation = new File(path).getAbsoluteFile().getCanonicalFile();
IVMInstallType instType = null;
for( IVMInstallType i : JavaRuntime.getVMInstallTypes()){
if( i.getName().equals( "Standard VM" )){
instType = i;
break;
}
}
for( IVMInstall vm : instType.getVMInstalls()){
if( vm.getInstallLocation().equals(installLocation) ){
System.err.printf("JRE already installed: name=%s, path=%\n", name, path );
return;
}
}
IStatus valState = instType.validateInstallLocation(installLocation);
if( valState != null && !valState.isOK() ){
System.err.printf("JRE path is not valid: name=%s, path=%\n", name, path );
return;
}
VMStandin vmStandin = new VMStandin(instType, name);
vmStandin.setName(name);
vmStandin.setInstallLocation(installLocation);
IVMInstall vmReal = vmStandin.convertToRealVM();
JavaRuntime.setDefaultVMInstall(vmReal, new NullProgressMonitor());
JavaRuntime.saveVMConfiguration();
}
cu
Frank