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

KnockoutObservable<number> returns string when bound to an input in typescript

javascript knockout.js typescript

I use Knockout version 3.2.0 and its definitelyTyped definitions from nuget:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.