为什么我的程序在NetBeans中工作但在JAR中不工作

时间:2015-10-13 20:26:38

标签: java image netbeans jar executable

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

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

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

1 个答案:

答案 0 :(得分:0)

这就是我,我不得不改变帐户。 我从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?