Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / November 2007

Tip: Looking for answers? Try searching our database.

class loader getResourceAsStream

Thread view: 
Alexandre Jaquet - 13 Nov 2007 10:30 GMT
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
Lew - 13 Nov 2007 13:44 GMT
> 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?

Signature

Lew

Alexandre Jaquet - 13 Nov 2007 14:36 GMT
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
Lew - 13 Nov 2007 14:53 GMT
> 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.

>> 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?

That means *inside* the JAR.

Signature

Lew

Alexandre Jaquet - 13 Nov 2007 15:19 GMT
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.
Lew - 14 Nov 2007 01:45 GMT
> 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.

Signature

Lew



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.