Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Accessing Resources Embedded in a Dynamically Loaded JAR

Posted on 2010-11-19
4
Medium Priority
?
430 Views
Last Modified: 2012-05-10
I am dynamically loading a JAR and succesfully accessing one of its classes. I am doing this with JarClassLoader. FYI, I was also able to successfully do this with URLClassLoader.

My problem is that the JAR class that I am instantiating is unable to access an XML file cotained in one of the JAR's packages/directories --- a java.io.FileNotFound exception results. Things work fine when I load the JAR on the classpath, but I must do the dynamic load given the architecture within which this has to work.

....any suggestions....anyone?
0
Comment
Question by:robertgw31
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 92

Accepted Solution

by:
objects earned 2000 total points
ID: 34177150
pass the system classloader as the parent of the classloader you are creating

http://download.oracle.com/javase/6/docs/api/java/lang/ClassLoader.html#getSystemClassLoader()
0
 

Expert Comment

by:robertgw
ID: 34179715
I assumed that the system classloader was by default the parent of the classloader I was creatging, but I will try this.  This is interesting that establishing the system classloader as the parent of the classloader within which theJAR is being loaded is necessary for a class within that JAR to access a resource that is also within that JAR.
0
 
LVL 27

Expert Comment

by:mrcoffee365
ID: 37471900
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0

Featured Post

The top UI technologies you need to be aware of

An important part of the job as a front-end developer is to stay up to date and in contact with new tools, trends and workflows. That’s why you cannot miss this upcoming webinar to explore the latest trends in UI technologies!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Suggested Courses

704 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question