wood burning stoves 2.0*
The moose likes Java in General and the fly likes jar and URLClassloader problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "jar and URLClassloader problem" Watch "jar and URLClassloader problem" New topic
Author

jar and URLClassloader problem

Erwin DES
Greenhorn

Joined: Feb 26, 2003
Posts: 18
I have created a program that makes a copy of my program-files (in a folder) from a floppy disk (or CD) to a place on the C-drive.
Then I wanted to start a jar-file to launch my program. The call to this jar-file is functioning only when I execute it directly, but not automatically when calling it in the code after the copy-proces.
I have already figured out that it have to use URLClassloader or something but my code below does not work...
public static Object createObject(String name, String path) throws Exception {
URL classPath = new URL(path);
URLClassLoader classLoader = new URLClassLoader(new URL[]
{classPath});
Class clazz = classLoader.loadClass(name);
return clazz.newInstance();
}
Can anyone give me a solution to this problem?
Thanks,
EDS
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451

... but not automatically when calling it in the code after the copy-proces.

Could you explain what you mean here? Why do you need to call it twice?


Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: jar and URLClassloader problem