This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan 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 | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
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: 8805
    
    5
off to the intermediate forum


Spot false dilemmas now, ask me how!
(If you're not on the edge, you're taking up too much room.)
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: dynamically loading a class file from a jar file
 
Similar Threads
input from console
about Readline()
images in jar file
Stream classes
readUTF not working