node-java icon indicating copy to clipboard operation
node-java copied to clipboard

Hi is there a way to dynamically add classpaths?

Open meghnad-globalids opened this issue 6 years ago • 3 comments

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?

meghnad-globalids avatar Sep 12 '19 11:09 meghnad-globalids

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

jzakrzewski avatar Sep 12 '19 11:09 jzakrzewski

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

meghnad-globalids avatar Sep 12 '19 11:09 meghnad-globalids

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.

jzakrzewski avatar Sep 12 '19 12:09 jzakrzewski