Changing Classpath

S

Steve

When I add a Jar file to java.class.path with System.setProperty and then invoke the
loader, classes in the Jar file are not found. Is there a way to fix this? Does the JVM
use the original classpath or the new classpath?

[BTW, I know urlClassLoader works but there's one situation where I can't use this.]

Thanks

Steve
 
J

Joseph Millar

When I add a Jar file to java.class.path with System.setProperty and then invoke the
loader, classes in the Jar file are not found. Is there a way to fix this? Does the JVM
use the original classpath or the new classpath?

[BTW, I know urlClassLoader works but there's one situation where I can't use this.]

Changeing the system property java.class.path has no effect at all.
It's there for your information only, the JVM's classpath settings
have already been set up, the system property is just a copy of
what is used internally.

If you want to add a Jar to the classpath, you must do it before
the JVM starts. You can still modify the property and have your
own class loader make use of it, but that in no way effects the
JVM's original classpath setting.

--Joe
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top