从 jar 文件中提取 dll

发布于 2024-12-21 12:10:39 字数 1440 浏览 2 评论 0原文

从 jar 文件中提取 rxtxSerial.dll 时,它给出了此异常,

java.lang.NullPointerException
    at org.apache.commons.io.IOUtils.copyLarge(IOUtils.java:1383)
    at org.apache.commons.io.IOUtils.copy(IOUtils.java:1357)
    at weighmentdesk.Weighment.loadJarDll(Weighment.java:940)
    at weighmentdesk.Weighment$5.run(Weighment.java:569)
    at java.awt.event.InvocationEvent.dispatch(Unknown Source)
    at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
    at java.awt.EventQueue.access$000(Unknown Source)
    at java.awt.EventQueue$1.run(Unknown Source)
    at java.awt.EventQueue$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown
Source)
        at java.awt.EventQueue.dispatchEvent(Unknown Source)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
        at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        at java.awt.EventDispatchThread.run(Unknown Source)

我正在查找该文件

getClass().getResourceAsStream("resources\\rxtxSerial.dll")

是否有任何问题。如果没有,是否有任何替代解决方案将 dll 文件提取到系统根目录(system32)中。

提前致谢。

While extracting the rxtxSerial.dll from the jar file it is giving this exception

java.lang.NullPointerException
    at org.apache.commons.io.IOUtils.copyLarge(IOUtils.java:1383)
    at org.apache.commons.io.IOUtils.copy(IOUtils.java:1357)
    at weighmentdesk.Weighment.loadJarDll(Weighment.java:940)
    at weighmentdesk.Weighment$5.run(Weighment.java:569)
    at java.awt.event.InvocationEvent.dispatch(Unknown Source)
    at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
    at java.awt.EventQueue.access$000(Unknown Source)
    at java.awt.EventQueue$1.run(Unknown Source)
    at java.awt.EventQueue$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown
Source)
        at java.awt.EventQueue.dispatchEvent(Unknown Source)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
        at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        at java.awt.EventDispatchThread.run(Unknown Source)

I am locating the file with

getClass().getResourceAsStream("resources\\rxtxSerial.dll")

is there any problem. If not is there any alternative solution to extract dll file into system root directory (system32).

Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

烟花肆意 2024-12-28 12:10:39

getClass().getResourceAsStream("resources\rxtxSerial.dll") 很可能返回 null
如果它位于 jar 文件的根目录中 try :

getClass().getResourceAsStream("/rxtxSerial.dll")

如果它位于名为 resources 的目录下 try :

getClass().getResourceAsStream("/resources/rxtxSerial.dll")

等等...

quite possibly getClass().getResourceAsStream("resources\rxtxSerial.dll") is returning null
if it's in the root of the jar file try :

getClass().getResourceAsStream("/rxtxSerial.dll")

if it's under a dir named resources try :

getClass().getResourceAsStream("/resources/rxtxSerial.dll")

and so on...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文