This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Java in General and the fly likes dynamically loading a class file from a jar file Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "dynamically loading a class file from a jar file" Watch "dynamically loading a class file from a jar file" New topic
Author

dynamically loading a class file from a jar file

Srinivas Ramgopal
Ranch Hand

Joined: Aug 06, 2006
Posts: 63
Hi all,

I wrote a java program to load a .class file from a jar file.
The .class file resides in a different namespace than that of this java program.

I am using Class.forName(fully qualified class name) which is throwing a java.lang.ClassNotFoundException exception during runtime.

Code is as follows:



Any input is highly appreciated.

Thanks in advance.
Freddy Wong
Ranch Hand

Joined: Sep 11, 2006
Posts: 959

I don't think that's how to dynamically load a JAR. Try to use URLClassLoader.



SCJP 5.0, SCWCD 1.4, SCBCD 1.3, SCDJWS 1.4
My Blog
Bert Bates
author
Sheriff

Joined: Oct 14, 2002
Posts: 8712
off to the intermediate forum


Eliminate fossil fuel subsidies. (If you're not on the edge, you're taking up too much room.)
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: dynamically loading a class file from a jar file
 
Similar Threads
input from console
Stream classes
readUTF not working
images in jar file
about Readline()