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???