通过本机代码从 jar 访问文件
我有一个小程序,其中包含一些图像、常规 java 类和通过 JNI 使用 C 代码的类。所有这些都包含在 jar 文件中,并且相应的 dll 位于硬盘驱动器上的某个位置。在 C 代码中,我必须从小程序(jar)中读取位图。我知道通过 getResourceAsStream() 方法从 java 访问该文件很简单,但是我可以从本机代码中执行此操作吗?
我知道我可以将位图的字节传递给本机代码作为解决方法,但它需要一些重写,所以我想避免这种情况。
那么,有没有办法通过本机代码访问 jar 内的文件,并由属于该 jar 的类执行?
I have an applet which contains some images, regular java classes and class, which uses C code via JNI. All this is included in jar file, and the appropriate dll is located somewhere on a harddrive. In C code I have to read a bitmap from the applet(jar). I know that it is simple to access this file from java via getResourceAsStream() method, but can I do it from native code?
I understand that I can pass the bytes of the bitmap to native code as a workaround, but it requires some rewriting, so I would like to avoid this.
So, is there any way to access files from within jar via native code, executed by class belonging to this jar?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只需调用适当的 Java 方法。
Just call the appropriate Java methods.