通过本机代码从 jar 访问文件

发布于 2024-10-05 03:40:22 字数 287 浏览 1 评论 0原文

我有一个小程序,其中包含一些图像、常规 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文