0

I wrote a file copy program for my Mac using Java. When I export a runnable .jar from Eclipse everything works great. So I bundle it up as a .app and I run the app. Everything looks fine, the GUI loads, but when I tell it to copy the exact same files from the same location as earlier, it just sits there. No files are copied, but it doesn't show as unresponsive.

My source files I am trying to copy to a new folder in my desktop are under /Library/Application Support/My Files.

Since the system see's my Java application as a .app and not .jar do I need to request admin priveledges from the user?

When I run my app from Terminal using the sudo command it outputs a bunch of data.

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
Dr-ZoidBerg
  • 41
  • 3
  • 10
  • Please post some code. Did you try debugging? – Miserable Variable Dec 16 '13 at 18:54
  • I ran my app using sudo from the Terminal. I posted what it outputted when I clicked the button to backup the files. – Dr-ZoidBerg Dec 16 '13 at 19:40
  • 1
    I don't know how Mac Apps are created from Jar files but the error message shows that `org/apache/commons/io/FileUtils` is not in `classpath. Is there a way to specify additional jars in classpath in the process to "bundle it up as an app" ? – Miserable Variable Dec 16 '13 at 20:51
  • @Miserable Variable I feel so stupid, I added the Apache Commons jar to my application and changed the info.plist to reflect that. Now it runs fine, you are the man. How can I submit your comment as the correct answer? – Dr-ZoidBerg Dec 18 '13 at 16:16
  • If it is any consolation, I have been making stupid mistakes for 25 years. I have added a reply with comments. Welcome to SO :) – Miserable Variable Dec 18 '13 at 16:59

1 Answers1

0

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

I don't know how Mac Apps are created from Jar files but the error message shows that org/apache/commons/io/FileUtils is not in classpath. Is there a way to specify additional jars in classpath in the process to "bundle it up as an app"?

Miserable Variable
  • 28,432
  • 15
  • 72
  • 133