I'm trying to create JVM 7 from C++ code and struggling with setting the right classpath. I want to specify a classpath using wildcards: e.g. /path/to/* (to include all the jars in the folder to the classpath)
If I'm setting a classpath via
options[0].optionString = "-Djava.class.path=/path/to/*;";
then my class is not found. I tried backslashes (I'm using Windows 8), with and without semicolon, nothing helped. This actually does not work from a command line either.
Then I tried to provide a "-cp" option, but in this case a JVM failed to be created. I tried:
options[0].optionString = "-cp=/path/to/*";
options[0].optionString = "-cp /path/to/*";
options[0].optionString = "-classpath=/path/to/*";
options[0].optionString = "-classpath /path/to/*";
options[0].optionString = "-cp";
options[0].extraInfo = "/path/to/*";
options[0].optionString = "-cp";
options[1].optionString = "/path/to/*";
None of those helped.
Do you have an idea how to provide a classpath with wildcards when creating a JVM from C++?
Thanks in advance
You will need to perform the expansion yourself because this is a feature of the Java launcher, not a feature of the JNI API. See the SetClassPath function in the launcher source, which calls the internal JLI_WildcardExpandClasspath function and then adds a -Djava.class.path option.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With