Can C++ Application load the .jar File using JNI?

后端 未结 1 730
遇见更好的自我
遇见更好的自我 2021-01-03 04:52

Thanks for having a look at question. I am trying to invoke a java method which is in class files using JNI interface. In turn the called class file should be executing the

相关标签:
1条回答
  • 2021-01-03 05:12

    Your question isn't completely clear, but I will give a general answer...

    In Java there is only two ways to get Java to look in a .jar file (and they really boil down to one way in the end), and that's to specify the .jar file in the classpath, or to create a classloader that will look in that jar file and add it to the list of classloaders Java will use.

    And, of course, all the classpath is is a set of classloaders that Java instantiates and uses before your program even starts.

    So a JNI program needs to make the Java calls (which I'm not looking up just now) to set up a new class loader and get Java to start using it if the JNI program needs Java to start looking in additional .jar files.

    0 讨论(0)
提交回复
热议问题