Results 1 to 1 of 1
  1. #1
    Naismith is offline Member
    Join Date
    Dec 2010
    Posts
    1
    Rep Power
    0

    Default 2 Problems: Uploading to Webserver and Converting Applet to Application

    I have developed a Japplet game in Eclipse Helios, and I have been trying to upload it to a webserver, however, I am getting strange errors whenever I try to run it from the web page (works perfectly in applet viewer). I have taken my entire bin directory, which contains media files used by the applet and the package folder with the classes, and I have placed it on the webserver. Then I used the following code to try to run it:
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <meta content="text/html; charset=ISO-8859-1"
    http-equiv="content-type">
    <title>Game</title>
    </head>
    <body>
    <br>
    <p>My Game:</p>
    <pre><applet code="<myclass>.class"
    codebase="bin/<package>/"
    height="800" width="1600">
    </applet>
    </pre>
    <br>
    </body>
    </html>

    I have been getting error messages such as this:
    java.lang.NoClassDefFoundError: <myclass> (wrong name: <package>/<myclass> at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClassCond(Unknown Source)
    at java.lang.ClassLoader.defineClass(Unknown Source)
    at java.security.SecureClassLoader.defineClass(Unknow n Source)
    at sun.plugin2.applet.Applet2ClassLoader.findClass(Un known Source)
    at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(U nknown Source)
    at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Un known Source)
    at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Un known Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Unk nown Source)
    at sun.plugin2.applet.Plugin2Manager.createApplet(Unk nown Source)
    at sun.plugin2.applet.Plugin2Manager$AppletExecutionR unnable.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
    Exception: java.lang.NoClassDefFoundError: <myclass> (wrong name: <package>/<myclass>)

    Or this (depending on minor changes I tried in the code):
    java.lang.ClassFormatError: Incompatible magic value 1008821359 in class file <myclass> at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClassCond(Unknown Source)
    at java.lang.ClassLoader.defineClass(Unknown Source)
    at java.security.SecureClassLoader.defineClass(Unknow n Source)
    at sun.plugin2.applet.Applet2ClassLoader.findClass(Un known Source)
    at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(U nknown Source)
    at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Un known Source)
    at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Un known Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Unk nown Source)
    at sun.plugin2.applet.Plugin2Manager.createApplet(Unk nown Source)
    at sun.plugin2.applet.Plugin2Manager$AppletExecutionR unnable.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
    Exception: java.lang.ClassFormatError: Incompatible magic value 1008821359 in class file <myclass>

    Can anyone please tell me what I am doing wrong here, and if possible, give me html code that will run it?

    Also, I have tried to convert the applet to an application by adding the following code to my launching class file:
    // public static void main(String[] args) {
    // JFrame f = new JFrame("Game");
    // f.setBounds(100,100,1700,900);
    // f.setTitle("<gametitle>");
    // f.setVisible(true);
    // JApplet applet = new <myclass>();
    // applet.init();
    // applet.start();
    // f.setContentPane(applet.getContentPane());
    // f.setDefaultCloseOperation(WindowConstants.EXIT_ON _CLOSE);
    // f.validate();
    // }

    but I get nullpointer exceptions all over the init() method, even though it works perfectly when I run it as an applet.

    Is there some way to fix this?

    Thanks.
    Last edited by Naismith; 12-10-2010 at 10:37 AM. Reason: Fix Typo

Similar Threads

  1. Converting this Applet to an Application
    By karthus in forum New To Java
    Replies: 4
    Last Post: 07-07-2010, 04:30 AM
  2. Write file to webserver from an Applet
    By sanoj_av in forum Java Applets
    Replies: 7
    Last Post: 05-14-2010, 03:39 AM
  3. Converting java application to applet
    By rcj66 in forum Java Applets
    Replies: 2
    Last Post: 03-16-2010, 07:41 PM
  4. Converting simple Java Application to Applet
    By jrohde in forum Java Applets
    Replies: 1
    Last Post: 07-25-2009, 07:48 PM
  5. Replies: 1
    Last Post: 03-27-2009, 05:47 PM

Posting Permissions

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