|
Re: Eclipse classpath variables programmatically [message #327525 is a reply to message #326353] |
Wed, 23 April 2008 14:17 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) |
Eclipse User![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=) |
|
|
|
Originally posted by: automatic.javalobby.org
Ok, I found the answer myself..
I could use JavaCore.getClasspathVariable(String variablename). But i
cannot use it in a headless plug-in.
The specific scenario I had in mind was to use the path pointed to by a
classpath variable in a launch configuration. I was trying to build a launch
configuration programmatically. For that purpose, there is a simple method
call in the JavaRuntime class which acheives this:
Here's an example:
IRuntimeClasspathEntry bootstrapEntry =
JavaRuntime.newVariableRuntimeClasspathEntry(new Path("JRE_LIB"));
And, if you look at the lauch configuration, you can add entries to the
bootstrap classpath or the user-defined classes. To add this environment
variable entry to the bootstrap classpath, you just need to say:
bootstrapEntry.setClasspathProperty(IRuntimeClasspathEntry.B OOTSTRAP_CLASSES);
OR if you need to add it to the user-defined entries, you would say:
IRuntimeClasspathEntry userEntry =
JavaRuntime.newVariableRuntimeClasspathEntry(new Path("JRE_LIB"));
userEntry.setClasspathProperty(IRuntimeClasspathEntry.USER_C LASSES);
Or if you want to make another entry, and still add it to classpath , but
not display it in the "classpath" tab al all (kinda hiding it), you would
say:
IRuntimeClasspathEntry hiddenOrDefaultEntry =
JavaRuntime.newVariableRuntimeClasspathEntry(new Path("JRE_LIB"));
hiddenOrDefaultEntry
setClasspathProperty(IRuntimeClasspathEntry.STANDARD_CLASSES );
This would add the entry to the classpath, but the entry would not be
displayed in the launch configuration's classpath tab.
Another example: If you wanted to add an external jar file to the
user-defined classes section of the classpath, you would do that with the
following couple of lines:
IRuntimeClasspathEntry myJarEntry =JavaRuntime.
newArchiveRuntimeClasspathEntry(new Path("/usr/lib/myjarfile.jar"));
myJarEntry.setClasspathProperty(IRuntimeClasspathEntry.USER_ CLASSES);
Hope this helps anyone who tries to build a launch config programmatically.
It aslo helps to read the article at:
http://www.eclipse.org/articles/Article-Java-launch/launchin g-java.html
|
|
|
Powered by
FUDForum. Page generated in 0.04046 seconds