This week's book giveaway is in the Design forum.
We're giving away four copies of Building Microservices and have Sam Newman on-line!
See this thread for details.
The moose likes Java in General and the fly likes How can I change classpath at runtime? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Building Microservices this week in the Design forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "How can I change classpath at runtime?" Watch "How can I change classpath at runtime?" New topic

How can I change classpath at runtime?

bhuvan gupta

Joined: Mar 26, 2001
Posts: 13

System.setProperty("java.class.path","%x%"); is executed,
shows new classpath, but
throws an exception.
I know this is a bug in JDK .. but is there any alternative to change classpath at runtime ?
Matt Senecal
Ranch Hand

Joined: Dec 01, 2000
Posts: 255
I don't think you can change the CLASSPATH at runtime.
An alternative, if you know what classes you're going to use ahead of time, is to use a class derived from ClassLoader. This will let you load and use classes without relying on the CLASSPATH.

There's nothing more dangerous than a resourceful idiot. ---Dilbert
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link:
subject: How can I change classpath at runtime?
It's not a secret anymore!