Specifying An Alternative JRE In Eclipse For An Application Launched From Eclipse

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.

Answers


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.


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)


Need Your Help

How to test network protocol?

sockets networking tcp protocols command-line-interface

I'm currently doing some research including comparing efficiency, accuracy and flexibility of different transport protocols such like tcp, udp and a new protocol based on udp we're currently design...

Javascript- How to return an array by with a string as parameter?

javascript arrays function

For a simple function, how can I return an array with a string as a parameter? I want the array to split the string at the spaces so it returns as [" ", " "].