【问题标题】:Why my program work in NetBeans but not in JAR为什么我的程序可以在 NetBeans 中运行,但不能在 JAR 中运行
【发布时间】:2016-01-11 18:06:43
【问题描述】:

我的项目真的很艰难。 当我在 NetBeans 中进行调试时,当我打开我的 .jar 时它工作正常,它停止在此:

String userdir = System.getProperty("user.dir");
    BufferedImage bimg = ImageIO.read(new File(userdir + "\\src\\resource\\" + filename));

程序正在处理图像文件,将它们复制到 src ,然后制作矩阵 RGB。

【问题讨论】:

  • 它给出了什么异常?
  • 确切的错误信息、堆栈跟踪等是什么?

标签: java image netbeans jar executable


【解决方案1】:

那是我,我不得不更改帐户。 我从 cmd 调试。

    SEVERE: null
java.nio.file.NoSuchFileException: C:\Users\macie\Documents\wallhaven-267510.jpg
 -> C:\Users\macie\Documents\NetBeansProjects\JavaApplication5\dist\src\resource
\wallhaven-267510.jpg
        at sun.nio.fs.WindowsException.translateToIOException(Unknown Source)
        at sun.nio.fs.WindowsException.rethrowAsIOException(Unknown Source)
        at sun.nio.fs.WindowsFileCopy.copy(Unknown Source)
        at sun.nio.fs.WindowsFileSystemProvider.copy(Unknown Source)
        at java.nio.file.Files.copy(Unknown Source)
        at javaapplication5.Copy.Copy(Copy.java:36)
        at javaapplication5.Menu.jButton3ActionPerformed(Menu.java:286)
        at javaapplication5.Menu.access$300(Menu.java:27)
        at javaapplication5.Menu$4.actionPerformed(Menu.java:96)
        at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
        at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
        at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
        at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
        at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Sour
ce)
        at java.awt.Component.processMouseEvent(Unknown Source)
        at javax.swing.JComponent.processMouseEvent(Unknown Source)
        at java.awt.Component.processEvent(Unknown Source)
        at java.awt.Container.processEvent(Unknown Source)
        at java.awt.Component.dispatchEventImpl(Unknown Source)
        at java.awt.Container.dispatchEventImpl(Unknown Source)
        at java.awt.Component.dispatchEvent(Unknown Source)
        at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
        at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
        at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
        at java.awt.Container.dispatchEventImpl(Unknown Source)
        at java.awt.Window.dispatchEventImpl(Unknown Source)
        at java.awt.Component.dispatchEvent(Unknown Source)
        at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
        at java.awt.EventQueue.access$500(Unknown Source)
        at java.awt.EventQueue$3.run(Unknown Source)
        at java.awt.EventQueue$3.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionP
rivilege(Unknown Source)
        at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionP
rivilege(Unknown Source)
        at java.awt.EventQueue$4.run(Unknown Source)
        at java.awt.EventQueue$4.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionP
rivilege(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)

我想我不能将文件复制到 jar 中?

【讨论】:

    猜你喜欢
    • 2015-11-10
    • 2020-03-24
    • 1970-01-01
    • 1970-01-01
    • 2017-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多