JApplet - Not Loading

View: New views
2 Messages — Rating Filter:   Alert me  

JApplet - Not Loading

by hinzsa :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi every one, I did this test applets

import java.awt.BorderLayout;
import javax.swing.JApplet;
import javax.swing.JButton;
public class TestJApplet extends JApplet {
@Override
public void init() {
this.setLayout(new BorderLayout());
JButton button = new JButton("TEST THIS");
this.add(button);
}
}


I build it using netbeans get the jar file: "TestApplet.jar"

I created the test hmtl file and add this code


<applet code="TestJApplet.class" codebase="." archive="TestApplet.jar" width=500
height=500 alt="test applet">


I also tryed this one

< object classid="clsid:CAFEEFAC-0016-0000-0000-ABCDEFFEDCBA">
< param name="archive" value="TestApplet.jar">
< param name="code" value="TestJApplet">

< embed code="TestJApplet" archive="TestApplet.jar" type="application/x-java-applet;jpi-version=1.6">
 < noembed>
No Java Support.
</noembed >


< object>



I TEST IT IN MY LOCAL MACHINE AND IT WORKS FINE, BUT WHEN i DEPLOY IT ON LINE, THE JAVA CONSOLE THROW THIS EXCEPTION

load: class TestJApplet not found.
java.lang.ClassNotFoundException: TestJApplet
at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Unknown Source)
at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(Unknown Source)
at java.io.BufferedInputStream.fill(Unknown Source)
at java.io.BufferedInputStream.read1(Unknown Source)
at java.io.BufferedInputStream.read(Unknown Source)
at sun.net.www.http.HttpClient.parseHTTPHeader(Unknown Source)
at sun.net.www.http.HttpClient.parseHTTP(Unknown Source)
at sun.net.www.http.HttpClient.parseHTTP(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at java.net.HttpURLConnection.getResponseCode(Unknown Source)
at sun.plugin2.applet.Applet2ClassLoader.getBytes(Unknown Source)
at sun.plugin2.applet.Applet2ClassLoader.access$000(Unknown Source)
at sun.plugin2.applet.Applet2ClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
... 7 more
Exception: java.lang.ClassNotFoundException: TestJApplet


THIS USED BE VERY STRAIGHT FORWARDS AND IT WORKED FINE.

COULD ANYONE PLEASE, HAVE THE KINDNESS TO GO BACK TO OUR BELOVED APPLET TECHNOLOGY AND THROW SOME LIGHT ON THIS MATTER?

IT WOULD BE VERY MUCH APPRECIATED.

REGARDS

jinzsa

Re: JApplet - Not Loading

by hinzsa :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

After burning my fingers, adding and putting and extracting, re installing jres and jdks.

I started from the beggining deleting all the class files from the browser cache.
and came back to this basic html applet tag code.

<applet code="Testjapplet.class" archive="testjapplet.jar" width="500" height="500"></applet>

the applet came to life. (thanks to this I could revive an old applet).


This are the point to be considered when you want to run an applet.

One JVM. I deleted all of them and installed a brand new one.
recompiled your application with the latest JDK. (consider refactoring your application)
build into a jar file, (keep it neat)
if you ftp to your server, make sure you use binary transfer
make sure you clear you cache in your browser, Firefox for example, will keep loading the applets.

in this case, the applet class is in not in a package.

Sometimes we go around in circles with simple things, and we are embarrased to ask.

I hope it helps.