I am trying to specify an alternative jre (my default is 1.6 and i need to run with jdk 1.4.2) in Eclipse, for an application that i shall launch from eclipse. I am not sure if I am doing the right thing in the following code:
Path jreContainerPath = new Path('/usr/lib/jvm/j2sdk1.4.2_18/'); IVMInstall jre = JavaRuntime.getVMInstall(jreContainerPath); workingCopy.setAttribute(IJavaLaunchConfigurationConstants. ATTR_JRE_CONTAINER_PATH, jre.getName());
However, the IVMInstall jre is null. I think I am not specifying the container path right, but I am not sure. And I must do it in the program. I would gladly appreciate any help on this. Thanks in advance.
getVMInstallreturnsJREContainerInitializer.resolveVM(jreContainerPath)which in turn callsgetExecutionEnvironmentId().It takes the second segment of the path as the id of the JVM (see
getVMName()of the sameJREContainerInitializerclass)May be that means the expected path is not the literal one, but one like ‘/jvm/j2sdk1.4.2_18’, with ‘j2sdk1.4.2_18’ the name of one of the installed JREs of your eclipse configuration.
By analyzing the source classes some more, you should be able to figure out exactly what that method expects.