File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Mac OS and the fly likes setting classpath dynamically Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Mac OS
Bookmark "setting classpath dynamically" Watch "setting classpath dynamically" New topic
Author

setting classpath dynamically

Sandeep Lakshmipathy
Ranch Hand

Joined: Mar 05, 2002
Posts: 31
Dear friends,
The System.setProperty() allows the setting of the classpath at runtime on my local machine from an application. But I see that the classes are not loaded from them and ClassNotFounfException occurs. Is it that the classpath path at app load time is only considered ? Then why should they allow for setting the classpath property. I would loke to know if the above task could be done without using a custom classloader ?
Thanks


Sandeep Lakshmipathy
Steve Deadsea
Ranch Hand

Joined: Dec 03, 2001
Posts: 125
I have not found a way to set the classpath dynamically. However you don't have to use a custom classloader. The URLClassloader works just fine for this purpose. Here is some code I use to call some classes that are installed on Mac OS X but are not in the classpath for some reason:

All that to replace the commented out line that begins with //success =
[ April 11, 2002: Message edited by: Steve Deadsea ]
Sandeep Lakshmipathy
Ranch Hand

Joined: Mar 05, 2002
Posts: 31
Thanks
That was of help to me. It did the job.
Bye
Gerhard Greyvenstein
Greenhorn

Joined: Feb 17, 2005
Posts: 1
Thnx alot! I've been using XStream in conjunction with the Classloader and the classes that i loaded were situated in a .war file (i'm working with the j2ee architecture), after deploying an ejb file aswell the default classloader pointed to the wrong jar and thus i'm using the URLClassloader now.


null & void
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: setting classpath dynamically