File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How can I change classpath at runtime?

 
bhuvan gupta
Greenhorn
Posts: 13
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

System.setProperty("java.class.path","%x%"); is executed,
System.getProperty("java.class.path");
shows new classpath, but
Class.forName("some.class.that.is.in.%x%");
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
Posts: 255
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic