0

While making a game and putting it on a Canvas object, I use the following applet code:

package me.NoahCagle.game;

import java.applet.Applet;
import java.awt.BorderLayout;

public class GameApplet extends Applet {
private static final long serialVersionUID = 1L;

private Game game = new Game();

public void init() {
    setLayout(new BorderLayout());
    add(game, BorderLayout.CENTER);
}

public void start() {
    game.start();
}

public void stop() {
    game.stop();
}

}

HTML:

<applet archive="game.jar" code="me.NoahCagle.game.GameApplet" width="640" height="480"></applet>`

Then after I have this, I run it using Chrome, but this doesn't work. It throws me an InvocationTargetException

And the applet runs correctly in Eclipse.

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
Noah Cagle
  • 441
  • 1
  • 4
  • 6
  • can you share the stack trace? – sasankad Jan 03 '14 at 04:01
  • 1) Why code an applet? If it is due to spec. by teacher, please refer them to [Why CS teachers should stop teaching Java applets](http://programmers.blogoverflow.com/2013/05/why-cs-teachers-should-stop-teaching-java-applets/). 2) Why AWT rather than Swing? See my answer on [Swing extras over AWT](http://stackoverflow.com/a/6255978/418556) for many good reasons to abandon using AWT components. If you need to support older AWT based APIs, see [Mixing Heavyweight and Lightweight Components](http://www.oracle.com/technetwork/articles/java/mixing-components-433992.html). – Andrew Thompson Jan 04 '14 at 03:32
  • Please learn common [Java naming conventions](http://java.sun.com/docs/books/jls/second_edition/html/names.doc.html#73307) (specifically the case used for the names) for class, method & attribute names & use them consistently. – Andrew Thompson Jan 04 '14 at 03:33
  • 1) Always copy/paste error & exception output. 2) Ensure the [Java Console](http://www.java.com/en/download/help/javaconsole.xml) is configured to show for applets & JWS apps. If there is no output at the default level, raise it and try again. – Andrew Thompson Jan 04 '14 at 03:39

0 Answers0