Question

I am having a runtime error ONLY when I test my Java program on a mac computer. It tests perfectly fine on various Windows operating systems. This is the error message I get on a Mac computer...

Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: javax/swing/GroupLayout$Group at project.MainPanel.calculateButtonActionPerformed(MainPanel.java:198) at project.MainPanel.access$200(MainPanel.java:32) at project.MainPanel$3.actionPerformed(MainPanel.java:97) at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1882) at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2202) at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:420) at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258) at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236) at java.awt.Component.processMouseEvent(Component.java:5602) at javax.swing.JComponent.processMouseEvent(JComponent.java:3135) at java.awt.Component.processEvent(Component.java:5367) at java.awt.Container.processEvent(Container.java:2010) at java.awt.Component.dispatchEventImpl(Component.java:4068) at java.awt.Container.dispatchEventImpl(Container.java:2068) at java.awt.Component.dispatchEvent(Component.java:3903) at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4256) at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3936) at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3866) at java.awt.Container.dispatchEventImpl(Container.java:2054) at java.awt.Window.dispatchEventImpl(Window.java:1801) at java.awt.Component.dispatchEvent(Component.java:3903) at java.awt.EventQueue.dispatchEvent(EventQueue.java:463) at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatch! Thread.j ava:269) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:190) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:184) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:176) at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)\

I do not know why this is happening. Could the fact that I compiled the program on a Windows computer be the problem? That is the only thing that I could think of.

Was it helpful?

Solution

Under OS X the default version of Java is Java 1.5.

The only good Way to ensure the right jvm is with java Web start.

OTHER TIPS

Without being able to test this, I would assume that this is because the Java version that you compiled this under is greater than the Java version that you are running on your Macintosh.

I suggest that you check the versions of each and make sure that the version which you are running under Mac OS is the same, or later.

Alternatively, you could try using the "-target" option for javac to set an older version and see if that helps.

You have to upgrade your java version to 1.6 minimum. First of all you check your java version on terminal by typing "java -version" if you don't have the 1.6, go to the Spotlight, write java and in Java Preferences drag and drop Java SE 6 to the top of the list, and it was done. Exit and that's it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top