View Full Version : java applet error

09-16-2004, 06:18 PM
My Java Applet works fine on my Windows XP:
but when I test it on my Mac OS X, it does not work.. show the following message in the java applet window each message each time I run it.

Loading Java Applet ...

java.lang.NoSuchFieldError: BLACK

I thought JAVA language was compatible on mac and windows.

any help??

09-18-2004, 02:42 PM
Im not sure, but I dont think theres something wrong with the Java code.
The java.lang.NoClassDefFoundError comes when the the file cant be found.
If you type in 'java blablah' in the command promt thats ^ the error you get.

09-18-2004, 06:47 PM
Maybe you're using an extension that is not part of the standard runtime environment, but it happens to be installed on your Windows box (my guess: you used the Windows box to develop the applet so you have the SDK installed there but the Mac only has the JRE or the browser's Java plugin). It would help if you tried to pinpoint where the error is happening, and what class you're trying to use at that point. Or at least give us a bigger description (or a link) to your applet.


09-18-2004, 07:41 PM
I have SDK on my Windows but in Mac I have browser plugins.

the class is basic by it self, i upload it into the directory "web";
windows works, but not mac os x

package web;

import javax.swing.*;
import java.awt.event.*;
import java.awt.*;

* Java Applet class.
* @version 9/18/04
public class Test2 extends JApplet implements ActionListener
private static final String about = "SUCCESSFUL";
private static final String nameInfo = "JAVA Test";
private JPanel controlPanel, mainPanel;

* Setup the JApplet.
public void init()
controlPanel = new JPanel(new BorderLayout());
mainPanel = new JPanel(new BorderLayout());

JButton menuAbout = new JButton(about);

controlPanel.add(mainPanel, BorderLayout.CENTER);
controlPanel.add(menuAbout, BorderLayout.NORTH);

* Invoked when an action occurs.
* @param e action event.
public void actionPerformed(ActionEvent e)
if (e.getActionCommand().equals(about)) {
JOptionPane.showMessageDialog(null, about, nameInfo,


09-19-2004, 04:32 PM
Then you should check the plug-ins in your Mac to see if they support all the classes you're using. I don't use J2SE a lot, but AFAIK Swing wasn't a part of the core runtimes in older versions of the JRE. You might just need to update the plug-in.

You could write tests applets by taking out stuff (extra packages and classes) until they work. Also use try..catch blocks and printStackTrace() calls to help you pinpoint the exact place that the Exception is being thrown.