tags:

views:

740

answers:

2

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.

+3  A: 

Do you necessarily want to specify it in the program itself? Otherwise you could just go to the build path of the project and specify the alternative jre that you want to use. (right click on project -> java build path -> select jre -> click edit -> select alternate jre there)

trex279
yes, i must do this programmatically
AndreiC
+1  A: 

getVMInstall returns JREContainerInitializer.resolveVM(jreContainerPath) which in turn calls getExecutionEnvironmentId().

It takes the second segment of the path as the id of the JVM (see getVMName() of the same JREContainerInitializer class)

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.

VonC