Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use a custom classloader at compile time

Is it possible to specify a custom classloader for javac (or some alternative java compiler)?

I'd love such a feat because it would allow me to compile classes that use classes that are only found by my special classloader.

For the curious ones: I'd write a classloder that connects to a database and creates classes based on the tables it finds.

like image 707
Jens Schauder Avatar asked Dec 29 '22 22:12

Jens Schauder


1 Answers

When you run javac you can specify the classloader like so:

javac -J-Djava.system.class.loader=org.awesome.classloader sourcefile.java
like image 191
Hardwareguy Avatar answered Jan 12 '23 22:01

Hardwareguy