Du verwendest einen veralteten Browser. Es ist möglich, dass diese oder andere Websites nicht korrekt angezeigt werden. Du solltest ein Upgrade durchführen oder ein alternativer Browser verwenden.
Ich habe ein Ähnliches Problem wie MichiM von Gestern.
Ich habe einige Jar dateien als Bibliothek in mein Projekt eingefügt wenn Ich das Applet local starte funktioniert es auch alles.
Dann exportiere ich alles zusammen wieder zu einem Jar File und lade dieses auf den Webserver. Dann geht nichts mehr und ich kriege die Fehlermeldung
"Ausnahme: java.lang.NullpointerException"
Ich habe im Fenster Export schon alle Haken angeklickt.
Wenn ich ein einfaches Applet schreibe, welches nicht auf die neu eingebundenen Bibliotheken zugreift funktioniert es einwandfrei .
Hat jemand eine Idee was ich falsch mache
Eine NullPointerException heißt, dass etwas ein zeiger auf null ist. Guck was alles in der zeile steht, wo die exception auftritt und was davon null sein könnte.
java.lang.NoClassDefFoundError: de/siemens/simaticnet/itcp/gui/CLTextOut
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
at java.lang.Class.getConstructor0(Unknown Source)
at java.lang.Class.newInstance0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at sun.applet.AppletPanel.createApplet(Unknown Source)
at sun.plugin.AppletViewer.createApplet(Unknown Source)
at sun.applet.AppletPanel.runLoader(Unknown Source)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Exception in thread "Thread-4" java.lang.NullPointerException
at sun.plugin.util.GrayBoxPainter.showLoadingError(Unknown Source)
at sun.plugin.AppletViewer.showAppletException(Unknown Source)
at sun.applet.AppletPanel.runLoader(Unknown Source)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
java.lang.NullPointerException
at sun.plugin.util.GrayBoxPainter.showLoadingError(Unknown Source)
at sun.plugin.AppletViewer.showAppletStatus(Unknown Source)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Exception in thread "thread applet-de.siemens.simaticnet.itcp.example.example1.class" java.lang.NullPointerException
at sun.plugin.util.GrayBoxPainter.showLoadingError(Unknown Source)
at sun.plugin.AppletViewer.showAppletException(Unknown Source)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
und das Programm
Code:
package de.siemens.simaticnet.itcp.example;
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
import java.beans.*;
import de.siemens.simaticnet.itcp.api.*;
import de.siemens.simaticnet.itcp.gui.*;
public class example1 extends Applet implements PropertyChangeListener, ActionListener {
private CLTextOut cLTextOut1 =null ;
private CLTimer cLTimer1 = null;
private S7CP s7CP1 = null ;
private S7Device s7Device1 = null;
private S7Variable s7Variable1 = null;
public void init() {
super.init();
setName("Example");
setLayout(null);
setSize (426,240);
s7CP1 = new S7CP();
s7CP1.setHostString(new HostString("192.168.178.15:80"));
s7Device1 = new S7Device();
s7Device1.setSlot(2);
s7Variable1= new S7Variable();
s7Variable1.setS7Anypointer(
new S7Anypointer((int)5,(int)1,(int)131,(int)0, (int)100, (int)0));
s7Variable1.setVariableName("s7Variable1");
cLTimer1= new CLTimer();
cLTimer1.setDelay(2000);
cLTextOut1 = new CLTextOut () ;
cLTextOut1.setName("cLTextOut1");
cLTextOut1.setBounds(0,0,200,45);
cLTextOut1.setOutFieldSize(100);
cLTextOut1.setLabel("Value:");
//cLTextOut1.setUnit("");
add (cLTextOut1,cLTextOut1.getName());
s7CP1.addPropertyChangeListener(this);
s7Device1.addPropertyChangeListener(this);
cLTimer1.addActionListener(this);
s7Variable1.addPropertyChangeListener(this);
}
public void start() {
super.start();
}
public void stop() {
super.stop();
}
public void destroy() {
super.destroy();
S7Api.terminate();
}
public void propertyChange (PropertyChangeEvent evt) {
if (evt.getSource()==s7CP1);
s7Device1.propertyChange(evt);
if (evt.getSource()==s7Device1);
s7Variable1.propertyChange(evt);
if (evt.getSource()==s7Variable1);
cLTextOut1.propertyChange(evt);
}
public void actionPerformed(ActionEvent e) {
if (e.getSource()== cLTimer1) {
s7Variable1.processGet();
}
}
}
Aufrufen tuhe ich das Applet mit in der HTML seiute mit:
Habe zuerst ein neues Verzeichniss im Projekt angelegt dort hinein die Jar dateien Importiert , dann in den Projekteinstellungen eine neue Bibliothek erstellt und mit add Jar die dateien eingebunden.
Wenn ich dann export in Jar mache also meine Example.jar erstelle und das projekt schließe und meine Example.jar in einem neuen Projekt importiere sehe ich auch alle wichtigen Bibliotheken, die ich brauche. wie gesagt offline im appletviewer fuktst es ja auch.