Erro ao exibir Applet

Boa tarde pessoal, estou com o seguinte problema:

java.lang.NoClassDefFoundError: api_tn3270
at NewApplet.init(NewApplet.java:48)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

Estou usando uma API chamada Mocha usada para se criar um emulador de terminal telnet, esta api está num arquivo.jar (tn3270.jar), já coloquei este .jar dentro do libraries e ja adicionei este library ao meu projeto, consigo compilar ele tranquilo, a classe que tento executar é um applet e nele é criada uma instancia deste emulador(api_tn3270.class), mas quando tento executar aparece este erro acima. Esta Classe api_tn3270 está dentro do .jar e é reconhecido, tanto que compila, o que pode estar acontecendo??

Applet que instancia a minha Classe api_tn3270…


import java.applet.*;

public class NewApplet extends Applet implements Runnable         
{
  private api_tn3270 my_emul;
  private Thread runner = null;            // thread of this program. Created in start
  
                                           
/*
  ----------------------------------------------------
  init
  ---------------------------------------------------- */
  public void init()
  {
    System.out.println("Hello Test World " );

    my_emul = new api_tn3270();        // lets use the tn3270 emulator in this test 
    try {
      my_emul.do_load_config(getDocumentBase(),"tn3270.cfg"); // load parameters
    } catch (Exception e) {
      System.out.println("Cannot access tn3270.cfg");
    }
    my_emul.use_display(false,false);            // set display type NON hide, NON application
  }
  
  /*
  ----------------------------------------------------
  start
  ---------------------------------------------------- */
  public void start()
  {
    runner = new Thread(this);
    runner.setPriority(Thread.MIN_PRIORITY);
    runner.start();  // now run will be called
  }
  /*
  ----------------------------------------------------
  run
  ---------------------------------------------------- */
  public void run()
  {
      // change HOSTNAME, before running the test
    String HOSTNAME = "linux";
    int HOSTPORT = 911;
    boolean more;
    String tmp;
    byte buf[][];
    byte fifo[];
    int x,y;
    System.out.println("Hello Test World " );

    System.out.println("Connect Status (should be false!) " + my_emul.get_connect_status());
    if (my_emul.do_connect(HOSTNAME,HOSTPORT) == true) { // make a telnet connection 
      
      more = true;
      my_emul.do_wait_input(2000);                   // wait on data
      System.out.println("-----------------DISPLAY 1 (DO_READ_ALL)--------------------");
      // display data in buf except empty lines
      my_emul.do_wait_input(8000);                   // wait on data
      buf = my_emul.do_read_all();                // "copy" all data to buf
      for(y=1;y<=24;y++) {
        tmp = "";
        boolean isdata = false;
        for(x=1;x<=80;x++) {
          tmp = tmp + (char) buf[y][x];
          if (buf[y][x] > ' ') isdata = true;
        }
        if (isdata == true) System.out.println("Line " + y + " " + tmp);
      } 
      System.out.println("-----------------DISPLAY 2 (GET_XY and GET_SCREEN_SIZE) --------------------");
      int cursor = my_emul.get_xy();
      System.out.println("Cursor at  y = " + (int)((cursor & 0xff00)/256) + " x = " + (int)(cursor & 0xff)); 
      int sizer = my_emul.get_screen_size();
      System.out.println("Screen size: width " + (int)((sizer & 0xff00)/256) + " height " + (int)(sizer & 0xff)); 
      
      System.out.println("-----------------DISPLAY 3 (TEXT MYLOGIN, key F2) --------------------");
      try { Thread.sleep(3000);} catch (InterruptedException e) {};
      if (my_emul.do_write_text("MYLOGIN") == false) 
        System.out.println("Sending text 'mylogin' failed");
      if (my_emul.do_aid_key(0xf2) == false) {
        System.out.println("aid key failed");
      }
      try {Thread.sleep(3000);} catch (InterruptedException e) {};
      System.out.println("-----------------DISPLAY 4 (DO_GOTO and DO_GOTO_FIELD) --------------------");
      System.out.println("goto 1,1");
      if (my_emul.do_goto(1,1) == false)
        System.out.println("goto failed");
      try {Thread.sleep(2000);} catch (InterruptedException e) {};
      System.out.println("goto 78,23");
      if (my_emul.do_goto(78,23) == false)
        System.out.println("goto failed");
      try {Thread.sleep(2000);} catch (InterruptedException e) {};
      for(int u = 1;u<4;u++) {
        System.out.println("goto field " +u + " now at field " + my_emul.get_field_pos());
        my_emul.do_goto_field(u);
        try {Thread.sleep(2000);} catch (InterruptedException e) {};
      }
      System.out.println("-----------------DISPLAY 5 (INSERT ERASE KEYS --------------------");
      if (my_emul.do_aid_key(0x1) == false) { //INSERT ON
        System.out.println("aid key failed");
      }
      try {Thread.sleep(1000);} catch (InterruptedException e) {};
      if (my_emul.do_aid_key(0x1) == false) { //INSERT OFF
        System.out.println("aid key failed");
      }
      if (my_emul.do_write_text("SMILE IN MORE THAN ONE FIELD") == false) 
        System.out.println("Sending text to host failed");
      try {Thread.sleep(3000);} catch (InterruptedException e) {};
      if (my_emul.do_aid_key(0x3) == false) { //ERASE FIELD
        System.out.println("erase field failed");
      }
      System.out.println("do erase field");
      try {Thread.sleep(4000);} catch (InterruptedException e) {};
      if (my_emul.do_aid_key(0x2) == false) { //ERASE ALL INPUT
        System.out.println("erase input failed");
      }
      System.out.println("do erase input");
      try {Thread.sleep(2000);} catch (InterruptedException e) {};
      my_emul.do_wait_input(2000);                   // wait on data
      System.out.println("-----------------DISPLAY 6 (DO_READ_ALL)--------------------");
      // display data in buf except empty lines
      my_emul.do_wait_input(8000);                   // wait on data
      buf = my_emul.do_read_all();                // "copy" all data to buf
      int height = my_emul.get_screen_size() & 0xff;
      for(y=1;y<=height;y++) {
        tmp = "";
        boolean isdata = false;
        for(x=1;x<=80;x++) {
          tmp = tmp + (char) buf[y][x];
          if (buf[y][x] > ' ') isdata = true;
        }
        if (isdata == true) System.out.println("Line " + y + " " + tmp);
      } 
      System.out.println("-----------------DISPLAY 7 (USER ACTION) --------------------");
      for(int t=0;t<10;t++) { // receive next 10 user actions and display them
        int act [] = my_emul.do_wait_user_action(2000,true,true);
        if (act.length > 0) {
          System.out.println("ACTION. size " + act.length);
          for (int k=0;k<act.length;k++) 
            System.out.println("AID " + (act[k] >> 24) + 
            " value " + ((act[k] & 0xff0000)>>16) + 
            " x " + ((act[k]>>8)&0xff) + 
            " y " + (act[k] & 0xff));
        }
        else
          System.out.println("Timeout number " + t + " of 10");
      }
      System.out.println("-----------------DISPLAY 8 (CONNECT STATUS and DISCONNECT) --------------------");
      System.out.println("Connect Status " + my_emul.get_connect_status());
      my_emul.do_disconnect();
      System.out.println("Connect Status " + my_emul.get_connect_status());
      
    } // endif connect
    System.out.println("Goodbye");
    //    System.exit(0);  // kill everything !!
}

} // end of object test

Jsp que abre o applet:

      <HTML>
      <HEAD>
      <TITLE> Mocha API TN3270 </TITLE>
      </HEAD>
      <BODY BGCOLOR=#FFFF20>
      <CENTER>
      <APPLET CODE="NewApplet" WIDTH="100%" HEIGHT="100%">
      </APPLET>
      </CENTER>
      </BODY>
      </HTML>

Alguém pode me ajudar???

Você não mencionou o JAR que você usou no atributo ARCHIVE do tag APPLET.

ESTE PARÂMETRO É NECESSÁRIO ??? O QUE OCORRE É QUE ESTE É UM EXEMPLO USADO PELA EMPRESA DESENVOLVEDORA DESTA API, este .jar seria referente a esta api ou ao meu projeto?? estou usando o Netbeans 5.5.1 … eu acreditava q este parametro arquive só era necessário caso ouvessem mais de uma classe para executar o applet!!! …
Se isto ajudar a api possui um .jar chamado TN3270.jar que já foi referenciado como biblioteca !!!

Vou lhe explicar como é que funciona o Sun Java Plug-In ou a Microsoft JVM.

  1. O browser IE ou Firefox lêem o tag < applet > e verificam qual é o plugin instalado e ativo (se é o da Sun ou o da Microsoft), além dos parâmetros e dos atributos da tag.
  2. Se houver um plugin instalado e ativo, o browser passa essa tag, parâmetros e atributos ao plugin.
  3. A seguir, o plugin pega o atributo “code” e vê se ele é um nome de classe. Por exemplo: “br.com.exemplo.Paranoia”.
  4. Se for um nome de classe, ele procura a classe no CLASSPATH. Mas o CLASSPATH do plugin não é o mesmo de uma aplicação desktop; ele consiste em:

a) O diretório virtual da página (por exemplo, se sua página fica em http://seusite.com.br/suaaplicacao/suapagina.html, ele procura no diretório virtual dessa página, ou seja, http://seusite.com.br/suaaplicacao/. Se ele for procurar uma classe br.com.exemplo.Paranoia, e ela estiver hospedada nesse diretório virtual, ela será procurada em:
http://seusite.com.br/suaaplicacao/br/com/exemplo/Paranoia.class
Quando você passa um diretório, assim como no comando java.exe, ele só procura .class, não .jar ou .zip.

b) Os arquivos .jar e .zip mencionados no atributo ARCHIVE. Exemplo:

Nesse caso, ele vai procurar em http://seusite.com.br/suaaplicacao/seujar.jar e http://seusite.com.br/suaaplicacao/outrojar.jar.

c) Dependendo do plugin, ele lê também os parâmetros (no caso do Sun Plug-In) ou (no caso da MSJVM)

O parâmetro “cache_archive” é útil quando você tem uma biblioteca grande e que raramente será atualizada, podendo ficar “cached” no browser.

cara … mas esse codigo eh exatamente o exemplo q veio com a api, mas enfim …

o meu arquivo da api está em C:\JavaPack\src\tn3270.jar,o código ficaria dessa forma então?:
<APPLET CODE=“classe.class” ARCHIVE="C:\JavaPack\src\tn3270.jar"
lembrando q o projeto está em outro lugar e acho que não dá pra por só o .jar pq as classes do projeto estão na pasta web-inf e não são visiveis fora de tal pasta…

Não mencione nome de arquivos (ARCHIVE=“C:\JavaPack\src\tn3270.jar”) dessa maneira; é porque o browser pode estar em uma máquina que não contenha esse jar nesse diretório.

Você deve pô-lo no mesmo diretório de sua página HTML (por exemplo), para que você possa fazer uma referência simples ao arquivo jar:

ARCHIVE=“tn3270.jar”