Mac Java应用程序以.jar的形式运行,但未能在捆绑为.app时正常运行。应用程序

我使用Java为我的Mac编写了一个文件复制程序。当我从Eclipse中导出可运行的.jar时,一切都很好。所以我将它捆绑为一个.app,然后运行该应用程序。一切看起来都很好,图形用户界面加载,但是当我告诉它从早期的相同位置复制完全相同的文件时,它就在那里。没有文件被复制,但不显示为无响应。Mac Java应用程序以.jar的形式运行,但未能在捆绑为.app时正常运行。应用程序

我想要复制到我桌面上的新文件夹的源文件位于/ Library/Application Support/My Files中。

由于系统将我的Java应用程序视为.app而不是.jar,是否需要向用户请求管理员密码?

当我使用sudo命令从终端运行我的应用程序时,它输出一堆数据。

MUS9155A271AL:~ sesa251707$ sudo /Users/sesa251707/Desktop/Notes\ Cloner\ Mac.app/Contents/MacOS/JavaApplicationStub 

Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: org/apache/commons/io/FileUtils

at Notes_Cloner$2.actionPerformed(Notes_Cloner.java:181)

at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2028)

at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2351)

at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)

at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)

at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)

at java.awt.Component.processMouseEvent(Component.java:6414)

at javax.swing.JComponent.processMouseEvent(JComponent.java:3275)

at java.awt.Component.processEvent(Component.java:6179)

at java.awt.Container.processEvent(Container.java:2084)

at java.awt.Component.dispatchEventImpl(Component.java:4776)

at java.awt.Container.dispatchEventImpl(Container.java:2142)

at java.awt.Component.dispatchEvent(Component.java:4604)

at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4618)

at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4279)

at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4209)

at java.awt.Container.dispatchEventImpl(Container.java:2128)

at java.awt.Window.dispatchEventImpl(Window.java:2492)

at java.awt.Component.dispatchEvent(Component.java:4604)

at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:717)

at java.awt.EventQueue.access$400(EventQueue.java:82)

at java.awt.EventQueue$2.run(EventQueue.java:676)

at java.awt.EventQueue$2.run(EventQueue.java:674)

at java.security.AccessController.doPrivileged(Native Method)

at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:86)

at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:97)

at java.awt.EventQueue$3.run(EventQueue.java:690)

at java.awt.EventQueue$3.run(EventQueue.java:688)

at java.security.AccessController.doPrivileged(Native Method)

at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:86)

at java.awt.EventQueue.dispatchEvent(EventQueue.java:687)

at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:296)

at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:211)

at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:201)

at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:196)

at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:188)

at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)

Caused by: java.lang.ClassNotFoundException: org.apache.commons.io.FileUtils

at java.net.URLClassLoader$1.run(URLClassLoader.java:202)

at java.security.AccessController.doPrivileged(Native Method)

at java.net.URLClassLoader.findClass(URLClassLoader.java:190)

at java.lang.ClassLoader.loadClass(ClassLoader.java:306)

at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)

at java.lang.ClassLoader.loadClass(ClassLoader.java:247)

... 37 more

回答:

Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: org/apache/commons/io/FileUtils

我不知道Mac应用程序如何从Jar文件创建,但该错误消息显示,组织/阿帕奇/公/ IO /文件实用程序不classpath。有没有一种方法可以在进程中的类路径中指定其他jar以“将其捆绑为应用程序”?

以上是 Mac Java应用程序以.jar的形式运行,但未能在捆绑为.app时正常运行。应用程序 的全部内容, 来源链接: utcz.com/qa/259855.html

回到顶部