At the moment I'm using bat file to launch my jar and set the java.system.class.loader. Is it possible to do this programmatically to get rid of the bat file?
Asked
Active
Viewed 1,734 times
5
-
Also see: [Replacement System Classloader for Classes In Jars containing Jars](http://stackoverflow.com/questions/5380275/replacement-system-classloader-for-classes-in-jars-containing-jars) – Christopher Peisert Jul 04 '12 at 18:17
1 Answers
5
You can't, because the system class loader is used before the first line of your program is executed.
You may use a different class loader for some classes, but you can't change the system class loader from your running program.

Denys Séguret
- 372,613
- 87
- 782
- 758
-
1+1 Or you can create a jar which detects whether the class loader is correct and if not, starts itself again with Runtime.exec() with the desired class loader – Peter Lawrey Jul 04 '12 at 18:09
-
1@dystroy, What about the solution posted by Nox http://stackoverflow.com/a/19128964/632951 – Pacerier Aug 25 '14 at 21:06