Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Jan 2004
    Posts
    61
    Thanks
    0
    Thanked 0 Times in 0 Posts

    java applet error

    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??

  • #2
    JPM
    JPM is offline
    Regular Coder
    Join Date
    Mar 2004
    Location
    Norway
    Posts
    204
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.
    <JPM />

  • #3
    Regular Coder
    Join Date
    Dec 2003
    Posts
    367
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #4
    New Coder
    Join Date
    Jan 2004
    Posts
    61
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

    Code:
    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);
        }
      }
      
    }

  • #5
    Regular Coder
    Join Date
    Dec 2003
    Posts
    367
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •