Applet asks for main method when executing, but does not have this method

Asked

Viewed 62 times

0

I packaged the project in a jar that is an applet and I want this applet to run here in the old firefox browser linux, however, it asks to select a main method, but Applet has no main method. How to make him perform?

inserir a descrição da imagem aqui

package xxx;

import java.applet.Applet;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.Button;
import java.awt.Graphics;
//import netscape.javascript.JSObject;

public class TesteApplet extends Applet {

    public String conteudo = "";
    public String formulario;
    public String campo;
    //public JSObject campoDoFormularioHTML; 
//
    public void init() {
          formulario = getParameter("formulario");
          campo = getParameter("campo"); 

          ActionListener trataEventos = new ActionListener(){


           public void actionPerformed(java.awt.event.ActionEvent e){
           conteudo += e.getActionCommand();
          // campoDoFormularioHTML.setMember("value", "" + conteudo);
           }

       };

       Button b7 = new Button("7");
       this.add(b7);
       b7.addActionListener(trataEventos);

       System.out.println();

       Button b8 = new Button("8");
       this.add(b8);
       b8.addActionListener(trataEventos);

       Button b9 = new Button("9");
       this.add(b9);
       b9.addActionListener(trataEventos);

       Button b4 = new Button("4");
       this.add(b4);
       b4.addActionListener(trataEventos);

       Button b5 = new Button("5");
       this.add(b5);
       b5.addActionListener(trataEventos);

       Button b6 = new Button("6");
       this.add(b6);
       b6.addActionListener(trataEventos);


       Button b1 = new Button("1");
       this.add(b1);
       b1.addActionListener(trataEventos);

       Button b2 = new Button("2");
       this.add(b2);
       b2.addActionListener(trataEventos);

       Button b3 = new Button("3");
       add(b3);
       b3.addActionListener(trataEventos);

       Button b0 = new Button("0");
       this.add(b0);
       b0.addActionListener(trataEventos);

       Button limpa = new Button("Limpa");
       this.add(limpa);
       limpa = new Button();
          // limpa.addActionListener(new ActionListener() {
    //      
//      public void actionPerformed(java.awt.event.ActionEvent e) {
//          conteudo = "";
//          campoDoFormularioHTML.setMember("VALUE", conteudo);
//      }
//     });
//              
//     JSObject objWin = JSObject.getWindow(this);
//     JSObject objDoc = (JSObject) objWin.getMember("document");
//     JSObject objForms = (JSObject) objDoc.getMember("forms");
//     JSObject objForm = (JSObject) objForms.getMember("formulario");
//     JSObject  objElements = (JSObject) objForms.getMember("elements");
//     campoDoFormularioHTML = (JSObject) objElements.getMember(campo);
//     campoDoFormularioHTML.setMember("value", ""); 
    }
}
  • See if the edits I made did not modify your intention in the question, I believe that thus, it becomes more objective. And see if your Applet has a method init(), which would be the equivalent of the main.

  • yes, it does. But I want a solution just that.

  • I understand, but you’re passing on too superficial information so we can help. Remember that we don’t know how it works or how your application was coded. See if the jar has manifest file, and if it is pointed to the class of your Applet that has this method init()

  • manifest? What do I put in it and where do I put it?

  • Are you trying to run applet by where? Direct from the browser or via linux terminal? If it is via terminal, which commands are you using?

  • good question not yet arrived in this part...but right in the same browser

  • Your class is stretching from java.applet.Applet? it would be interesting to add it so we can see if it’s a code error.

Show 2 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.