...

View Full Version : java applet error



VietBoyVS
09-16-2004, 05: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.NoClassDefFoundError
java.lang.NoSuchFieldError: BLACK
java.lang.NoClassDefFoundError


I thought JAVA language was compatible on mac and windows.


any help??

JPM
09-18-2004, 01: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.

shmoove
09-18-2004, 05: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.

shmoove

VietBoyVS
09-18-2004, 06: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);
menuAbout.setMnemonic('S');
menuAbout.setForeground(Color.BLUE);
menuAbout.addActionListener(this);

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


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

}

shmoove
09-19-2004, 03: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.

shmoove



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum