Hi All,

I have created a Java applet in Eclipse and ran it in eclipse, it works fine . To run the applet in Webbrowser it was mentioned to embed the .class file inside a webpage by creating a HTML file. My class name is MyFirstGUI. i have created a file name gui.html and saved it in my documents. The error im getting in browser when running the file is "ClassNotFoundException". This is the content of my html file .

<TITLE>Metric Conversion Helper</TITLE>
<APPLET code = “MyFirstGUI.class” width = “400” height = “120”>

Please Explain....

3 Years
Discussion Span
Last Post by murali2489

Make sure the class file is located in the same directory as the html file. also make sure it is actually an applet rather than an aplication (has an init and a paintComponent method and it extends JApplet).

Edited by sirlink99


i have created it in NetBeans sorry not in Eclipse as i mentioned, so it is saved inside netbeans projects folder, i have also cpoied the HTMl file to the same location which is " C:\Users\jacksons5\Documents\NetBeansProjects\myFirstGUI\build\classes\myfirstgui " . Its still throwing the same error.

Here is my code

 * To change this template, choose Tools | Templates
 * and open the template in the editor.

package myfirstgui;

import java.awt.event.ActionEvent;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionListener;

    private JTextField jtInput;
    private JTextField jtOutput;
    private static final int WIDTH = 600;
    private static final int HEIGHT = 100;

    public void init(){
        Container container = super.getContentPane();

        GridLayout gridlabel ;

        gridlabel = new GridLayout(3,2);


        JLabel jInput = new JLabel("Input",SwingConstants.CENTER);
        JLabel jOutput = new JLabel("Output",SwingConstants.CENTER);

         jtInput = new JTextField(10);
         jtOutput = new JTextField(10);


        JButton jbInput = new JButton("Calculate");
        jbInput.addActionListener(new CalculateJButtonInterface());



private class CalculateJButtonInterface implements ActionListener{

        public void actionPerformed(ActionEvent e) {
            int n,sum;

            n = Integer.parseInt(jtInput.getText());

            sum =  sum = ((n + 1) / 2) * n;
            jtOutput.setText("" + sum); 

            //throw new UnsupportedOperationException("Not supported yet.");


I have the class file and HTML file both in "C:\Users\jacksons5\Documents\NetBeansProjects\myFirstGUI\build\classes\myfirstgui".

I have tried putting Codebase in HTML file as

<APPLET code = “C:\Users\jacksons5\Documents\NetBeansProjects\myFirstGUI\build\classes\” width = “400” height = “120”>


<APPLET code = “C:\Users\jacksons5\Documents\NetBeansProjects\myFirstGUI\build\classes\MyFirstGUI.class” width = “400” height = “120”>

Still doesnot work.

Could you please tell what i need to put in <APPLET code to make it work in Browser

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.