Unable to Load resource from the jar [message #632062] |
Mon, 11 October 2010 12:31 |
|
I wanted to load files from the jar but i am getting a FileNotFoundException.
I have used the following code:-
There is IPath path which gives the Full path of the jar file ,
for eg. C:/Eclipse/plugins/com.animesh.pluginproject/lib/core.jar
try {
JarFile jarFile = new JarFile(path.toOSString());
Enumeration<JarEntry> entries = jarFile.entries();
while (entries.hasMoreElements()) {
JarEntry ze = (JarEntry) entries.nextElement();
String entryName = ze.toString();
String appendedPath = path + "!/" + ze.toString();
URI uri = URI.createFileURI(appendedPath);
URI jarUri = URI.createURI("jar:" + uri.toString());
ResourceSet rs = new ResourceSetImpl();
Resource resource = rs.createResource(jarUri, null);
resource.load(null);
}
} catch (IOException e) {
ErrorLoggingService.logError(ClassPathJarLoader.class, "getControlsFromClassPath", e.getMessage(), e, PhoenixServicesPlugin.getDefault()); //$NON-NLS-1$
}
When i am trying to load the resource using resource.load(null) , I get a FileNotFoundException.
Regards,
Animesh
|
|
|
Re: Unable to Load resource from the jar [message #632152 is a reply to message #632062] |
Mon, 11 October 2010 18:35 |
Ed Merks Messages: 33136 Registered: July 2009 |
Senior Member |
|
|
Animesh,
Comments below.
Animesh,
At which point in the code below do you get the FileNotFoundException?
Animesh Kumar wrote:
> I wanted to load files from the jar but i am getting a
> FileNotFoundException.
>
> I have used the following code:-
>
> There is IPath path which gives the Full path of the jar file ,
> for eg. C:/Eclipse/plugins/com.animesh.pluginproject/lib/core.jar
>
> try {
> JarFile jarFile = new JarFile(path.toOSString());
> Enumeration<JarEntry> entries = jarFile.entries();
> while (entries.hasMoreElements()) {
> JarEntry ze = (JarEntry) entries.nextElement();
> String entryName = ze.toString();
> String appendedPath = path + "!/" + ze.toString();
> URI uri = URI.createFileURI(appendedPath);
> URI jarUri = URI.createURI("jar:" + uri.toString());
> ResourceSet rs = new ResourceSetImpl();
> Resource resource = rs.createResource(jarUri, null);
> resource.load(null);
>
> }
>
> } catch (IOException e) {
> ErrorLoggingService.logError(ClassPathJarLoader.class,
> "getControlsFromClassPath", e.getMessage(), e,
> PhoenixServicesPlugin.getDefault()); //$NON-NLS-1$
> }
>
> When i am trying to load the resource using resource.load(null) , I
> get a FileNotFoundException.
>
>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.02029 seconds