0

I have an issue with a Java applet in Chrome. An error message: java(TM) platform SE8 U40 HAS crashed appears.

After searching the internet, I enabled Java in the browser. I also changed the Java security settings, but it still does not work.

Testing my applet using Applet Viewer command in a terminal produces an error message too:

java.lang.NoClassDefFoundError : firstapplet

In my folder i have class (FirstApplet.class) and the html page(page.html) and FirstApplet.java

page.html

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body bgcolor="#0000FF">

<applet code="FirstApplet" width="500" height="500"></applet>
</body>
</html>

FirstApplet.java

import java.applet.Applet;
import java.awt.Button;
import java.awt.Label;
import java.awt.TextField;

public class FirstApplet extends Applet{

    public void init(){
        add(new Label("Nom:"));
        add(new TextField(12));
        add(new Button("ok"));
    }
}

please help me to solve this problem thanks you

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
student
  • 39
  • 1
  • 5
  • Classes defined in the default package can not be loaded automatically by the JVM. Try placing the class within a package namespace. Also, consider using Swing over AWT based classes – MadProgrammer Apr 26 '15 at 08:02
  • 1) Why code an applet? If it is due to the teacher specifying it, 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 use AWT? See [this answer](http://stackoverflow.com/questions/6255106/java-gui-listeners-without-awt/6255978#6255978) for many good reasons to abandon AWT using components in favor of Swing. – Andrew Thompson Apr 27 '15 at 04:44
  • 1
    BTW - `java.lang.NoClassDefFoundError : firstapplet` Always copy/paste error and exception output rather than type 'something like' what the message is! – Andrew Thompson Apr 27 '15 at 04:47

0 Answers0