从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)。
提前致谢。
答案 0 :(得分:1)
很可能是getClass()。getResourceAsStream(“resources \ rxtxSerial.dll”)返回null 如果它在jar文件的根目录中,请尝试:
getClass().getResourceAsStream("/rxtxSerial.dll")
如果它位于名为resources的目录下,请尝试:
getClass().getResourceAsStream("/resources/rxtxSerial.dll")
依旧......