0

I'm just begining to learn applet tehnology in universitaty. Need an advice or help. I can't ru applet's html in browser. On starting it I have only a message "ClassNoFoundExeption". Work with Firefox+Eclipse+Xubuntu. I guess I installed all what I need in browser.

My simple code:

Pack/Recs.java
package Pack;
import java.applet.*;
import java.awt.*;

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

    int a;
    int b;
    String tempStr;

    public void start()
    {
        a = 50;
        b = 50;
        tempStr = "Hallo!"; 
    }
    public void paint(Graphics g)
    {
        g.drawString(tempStr, 10, 10);
        g.drawOval(20, 20, a, b);
    }
}

My html file:

<html>
    <head>
        <meta content="text/html; charset=UTF-8" http-equiv="content-type">
        <title>Java Applet</title>
    </head>
    <body>
        <h3>Java Applet</h3>
        <applet code="Pack.Recs.class" height="400" width="500">
            <param name=width_a value=100>
            <param name=height_a value=200>
             Your browser does not support the <code>applet</code> tag.
        </applet>
    </body>
</html>
okonik
  • 115
  • 1
  • 3
  • 10
  • I think you might put your class in wrong directory. you need to create a Pack folder in root folder of index.html, then put Recs.class file in it. or simply, move your class to default package (remove package Pack; line, move class file one step parent, compile and put root folder of index.html) – Adem Dec 19 '14 at 11:53
  • @Adem Yeah, I forgot to say. In the root folder I have applet.html and folder Pack. In folder Pack we have *.java file – okonik Dec 19 '14 at 12:27
  • Also, is no difference if I replace `` tag with ` – okonik Dec 19 '14 at 12:46
  • java file ? you should have .class file, not java – Adem Dec 19 '14 at 13:31
  • 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 Dec 21 '14 at 00:58

1 Answers1

0

I found a solution! I moved *.java file from pack and leaved it in /src root.

In html I actualized path to class and runned html file from /bin folder.

okonik
  • 115
  • 1
  • 3
  • 10