Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » Programmatically Create User Library
Programmatically Create User Library [message #256342] Fri, 12 September 2008 10:35 Go to next message
Eclipse UserFriend
Does anyone know a programmatic way to create a User Library?

I have created an extension that provides a "New Custom Project". This new
wizard allows a user to select a location for the code that will become
linked resources. I would like to also create a User Library that includes
several jar files that are located based on the root location the user
enters in the new wizard.

I have searched everywhere but it looks as if the only way to do this is
from JDT Internal packages which I would rather not mess with.

Thanks
Re: Programmatically Create User Library [message #256346 is a reply to message #256342] Fri, 12 September 2008 11:41 Go to previous messageGo to next message
Eclipse UserFriend
Michael wrote:
> Does anyone know a programmatic way to create a User Library?
>
> I have created an extension that provides a "New Custom Project". This
> new wizard allows a user to select a location for the code that will
> become linked resources. I would like to also create a User Library that
> includes several jar files that are located based on the root location
> the user enters in the new wizard.
>
> I have searched everywhere but it looks as if the only way to do this is
> from JDT Internal packages which I would rather not mess with.
>
> Thanks
>
Here is an example that creates a user library "MyUserLibrary" with one entry "/path/to/first.jar":

ClasspathContainerInitializer initializer= JavaCore.getClasspathContainerInitializer(JavaCore.USER_LIBR ARY_CONTAINER_ID);
final String libraryName = "MyUserLibrary";
final String firstJarPath = "/path/to/first.jar";
IPath containerPath = new Path(JavaCore.USER_LIBRARY_CONTAINER_ID);
initializer.requestClasspathContainerUpdate(containerPath.ap pend(libraryName), null, new IClasspathContainer() {
public IPath getPath() {
return new Path(JavaCore.USER_LIBRARY_CONTAINER_ID).append(libraryName) ;
}
public int getKind() {
return K_APPLICATION;
}
public String getDescription() {
return libraryName;
}
public IClasspathEntry[] getClasspathEntries() {
return new IClasspathEntry[] {
JavaCore.newLibraryEntry(new Path(firstJarPath), null, null)
};
}
});
Re: Programmatically Create User Library [message #533650 is a reply to message #256346] Fri, 14 May 2010 19:35 Go to previous message
Eclipse UserFriend
Hi, Jerome
Your example is very useful.

But I have another question, how can I get one exist User Library and its contained jars?
I know JavaCore.getUserLibraryNames() can return the user library name.
How can I get the defined user library's contained jars?
BTW, I do not have IProject.

Thanks!
Previous Topic:Custom Quick Assist - how to determine code indentation?
Next Topic:Create an OSX 10.5 standalone java app on 10.6?
Goto Forum:
  


Current Time: Mon Mar 24 10:14:10 EDT 2025

Powered by FUDForum. Page generated in 0.03212 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top