I'm using the following code for integrating my Java app with Mac OS X:
if (System.getProperty("os.name").equals("Mac OS X"))
{
System.setProperty("com.apple.mrj.application.apple.menu.about.name", "JoText"); // Program name
com.apple.eawt.Application.getApplication().setDockIconImage(new javax.swing.ImageIcon( JotextMain.class.getResource("icons/Icon.png") ).getImage()); // Dock icon
System.setProperty("apple.laf.useScreenMenuBar", "true"); // Use global menu bar
com.apple.eawt.Application.getApplication().addApplicationListener(new MacAboutAndQuit()); //Make "Quit" and "About" options work
}
On Mac OS X, it works fine. On Ubuntu however:
Exception in thread "main" java.lang.NoClassDefFoundError: com/apple/eawt/ApplicationListener
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2451)
at java.lang.Class.getMethod0(Class.java:2694)
at java.lang.Class.getMethod(Class.java:1622)
at sun.launcher.LauncherHelper.getMainMethod(LauncherHelper.java:494)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:486)
Caused by: java.lang.ClassNotFoundException: com.apple.eawt.ApplicationListener
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
... 6 more
When I comment out that code, it launches fine on Ubuntu. Strange, because it checks for Mac OS X first before executing Mac OS X specific operations. I don't have Windows, but friend of me using Windows also reported my .jar didn't launch and gives a "A Java Exception has occured" message from the Java Virtual Machine Launcher instead. On a Windows PC at school, same problem.
What's causing this?