class loader getResourceAsStream

A

Alexandre Jaquet

Hi,

I'm trying to get a resource who is stored into a jar file. I've the
following path to the resource from the root of the jar
WUI-CDM-Module/oams-profiles/Default/module/cdm/pageflow/
clientrelationship/MyName2.module

I've tryed many ways :

InputStream inputStream =
Thread.currentThread().getContextClassLoader().getResourceAsStream("WUI-
CDM-Module/oams-profiles/Default/module/cdm/pageflow/
clientrelationship/MyName2.module");


ClassLoader loader = IncludeFigure.class.getClassLoader();
InputStream inputStream = loader.getResourceAsStream("WUI-CDM-Module/
oams-profiles/Default/module/cdm/pageflow/clientrelationship/
MyName2.module");


ClassLoader.getSystemResourceAsStream("WUI-CDM-Module/oams-profiles/
Default/module/cdm/pageflow/clientrelationship/MyName2.module");

but without success

anybody know the tricks ?

Thanks

Regards,
Alexandre
 
L

Lew

Alexandre said:
Hi,

I'm trying to get a resource who is stored into a jar file. I've the
following path to the resource from the root of the jar
WUI-CDM-Module/oams-profiles/Default/module/cdm/pageflow/
clientrelationship/MyName2.module

Is that path in the same directory tree (within the JAR) as the classes? In
other words, is WUI=CDM-Module a direct subdirectory of the root of your class
tree?
 
A

Alexandre Jaquet

The jar file is included as an external resource of my project, it's
accessible in eclipse by selecting a node of the project tree
 
L

Lew

Alexandre said:
The jar file is included as an external resource of my project, it's
accessible in eclipse by selecting a node of the project tree

That's nice.


Is that path in the same directory tree (within the JAR) as the classes? In
other words, is WUI=CDM-Module a direct subdirectory of the root of your class
tree?

That means *inside* the JAR.
 
A

Alexandre Jaquet

In fact I'm using eclipse, the root of referenced class is "Referenced
Librairies" then I've the name of the jar and then WUI-CDM-Module as
the root folder of my jar.
 
L

Lew

Alexandre said:
In fact I'm using eclipse, the root of referenced class is "Referenced
Librairies" [sic] then I've the name of the jar [sic] and then WUI-CDM-Module as
the root folder of my jar.

Try putting a leading slash in the path of the resource.

I am guessing.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,982
Messages
2,570,185
Members
46,737
Latest member
Georgeengab

Latest Threads

Top