Solved

Accessing Resources Embedded in a Dynamically Loaded JAR

Posted on 2010-11-19
4
425 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 500 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

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

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

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

622 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