joeferner / node-java

Bridge API to connect with existing Java APIs.
MIT License
1.87k stars 281 forks source link

Hi is there a way to dynamically add classpaths? #484

Open meghnad-globalids opened 5 years ago

meghnad-globalids commented 5 years ago

Is there a way to dynamically add classpaths as while doing mocha tests for different database connectivities the jars will be added to classpath based on the driver type. It seems that the "ClassNotfound error" is a big problem, as jvm once created no longer checks for extra classes added. How do you suppose i do this?

jzakrzewski commented 5 years ago

AFAIK JVM generally does not let you do that. The way around would be to use own class loader.

meghnad-globalids commented 5 years ago

Is there a way to recreated the jvm? For class Loader i will need to know all classes

jzakrzewski commented 5 years ago

Many resources suggest it's not possible. Like this OpenJDK bug: https://bugs.openjdk.java.net/browse/JDK-4712793.

I'm not a Java programmer but I'm almost sure you could implement a class loader where you could "push classpath" at runtime.