Call Java from Rust with j4rs - get error when run with cargo run

I want to call some java packages from Rust with j4rs crate.
I download all the dependent jars and load them with JVM::deploy_artifact.
After I build the project with cargo build, I can directly run the binary without any error.
But when I run the project with cargo run, I will get the following error from java.

Exception in thread "main" java.lang.NoClassDefFoundError: org/astonbitecode/j4rs/api/instantiation/NativeInstantiationImpl
Caused by: java.lang.ClassNotFoundException: org.astonbitecode.j4rs.api.instantiation.NativeInstantiationImpl
	at java.lang.ClassLoader.loadClass(
	at sun.misc.Launcher$AppClassLoader.loadClass(
	at java.lang.ClassLoader.loadClass(
thread 'main' panicked at 'Jvm should be initiated: JavaError("An Exception was thrown by Java while creating global ref... Please check the logs or the console.")', src\

Does anybody know why?

What Java version are you using? I remember having some issues because mine was too old.

Are you on Windows? If so, I believe you should use j4rs v0.15.3 because in earlier versions there was an issue with UNC handling. The classpath was not populated correctly when running with cargo...

Thanks. I am on Windows and I am using jdk 1.8. :joy: I believe j4rs v0.15.3 uses logback v1.4.x compiled by Java major version 55 which is not compatible with jdk 1.8. I guess I have to tolerate this annoying bug right now.