Changing ClassPath

In C++, I Start a JVM with an CLASSPATH.

But during the life of my Application, I want to access a class, who's not in the original CLASSPATH.

I can't stop my App, and restart.

I wont to add my new jar in the classpath.

If I use System.SetProperty( "java.class.path", .....); The JVM doesn't reload it.

Help!

[363 byte] By [SANCERRY] at [2007-9-26 13:00:12]
# 1

You can't replace an existing jar once java has accessed it.

To load a class it must be found via

-The classpath on start up. The class path can not be changed after start up.

-In the 'ext' directroy.

-Via a user defined class loader.

The only way to 'reload' a class is to create your own class loader. For each 'reload' you get rid of all of the old instances and then create a new class loader. Search the forums for specific examples.

jschell at 2007-7-2 12:49:09 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 2
Hello,If you would like to change your classpath without restart your application you can use URLCLassLoader in your Java application.There is an application using URLClassLoader in the Java tutorial.Good luck.
arnaud.java at 2007-7-2 12:49:09 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 3
>If you would like to change your classpath without restart >your application you can use URLCLassLoader in your Java application.That doesn't change your class path. It changes the way classes are loaded.
jschell at 2007-7-2 12:49:09 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 4
That's right!What I would like to say to SANCERRY, it's URLClassLoader allows to load classes from jar file (for example) which are not in the classpath.
arnaud.java at 2007-7-2 12:49:09 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 5
Thanks! I try and it's OK
SANCERRY at 2007-7-2 12:49:09 > top of Java-index,Java HotSpot Virtual Machine,Specifications...