I think the problem has something to do with the Jar file. It would load the
class file fine but when i stick it in a self signed jar then it throws a
wobbler. here's what i did
c:\j2sdk1.4.2_06\bin\keytool -genkey -keyalg rsa -alias dazkey
c:\j2sdk1.4.2_06\bin\keytool -export -alias dazkey -file dazsuncert.crt
c:\j2sdk1.4.2_06\bin\jar cvf c:\applets\Helloserver.jar
c:\applets\Helloserver.class
c:\j2sdk1.4.2_06\bin\jarsigner c:\applets\Helloserver.jar dazkey
c:\j2sdk1.4.2_06\bin\jarsigner -verify -verbose -certs
c:\applets\Helloserver.jar
This is what the java console reported
Java Plug-in 1.5.0_04
Using JRE version 1.5.0_04 Java HotSpot(TM) Client VM
User home directory = C:\WINDOWS
----------------------------------------------------
c: clear console window
f: finalize objects on finalization queue
g: garbage collect
h: display this help message
l: dump classloader list
m: print memory usage
o: trigger logging
p: reload proxy configuration
q: hide console
r: reload policy configuration
s: dump system and deployment properties
t: dump thread list
v: dump thread stack
x: clear classloader cache
0-5: set trace level to <n>
----------------------------------------------------
load: class Helloserver.class not found.
java.lang.ClassNotFoundException: Helloserver.class
at sun.applet.AppletClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.applet.AppletClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.applet.AppletClassLoader.loadCode(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)
Caused by: java.io.IOException: open HTTP connection failed.
at sun.applet.AppletClassLoader.getBytes(Unknown Source)
at sun.applet.AppletClassLoader.access$100(Unknown Source)
at sun.applet.AppletClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
... 10 more
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-Helloserver.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)
The source is below
import java.awt.*;
import java.applet.*;
import java.net.*;
import java.io.*;
import java.security.*;
import java.lang.*;
public class Helloserver extends Applet
{
private String hostname = "
http://g7wap.dyndns.org/";
private String protocol = "http://";
private String port="80";
private URL location;
private Object content;
private String tmpStr = "GET / HTTP / 1.1\r\n\r\n";//Accept:
*/*\r\n\r\n";//Accept-Language: en-gb\r\n\r\nXXXXXXXXXXXXXXX:
XXXXXXXXXXXXX\r\n\r\nUser-Agent: HelloServer 1\r\n\r\n";
private byte[] getStr = tmpStr.getBytes();
public void init()
{
hello();
}
public void paint(Graphics g)
{
g.drawString(hostname, 50, 60 );
}
/**
* Method hello
*
*
* @return
*
*/
protected boolean hello()
{
String str,buf,server;
byte[] ba = new byte[1024];
int bytesRead;
Socket socket=new Socket();
buf="";
try
{
// O P E N
socket = new Socket();
socket.setSoTimeout(3000);
SocketPermission p1 = new SocketPermission("10.0.0.254:80",
"connect,accept,resolve");
socket.connect(new InetSocketAddress("10.0.0.254", 80),3000 );
}
catch(AccessControlException u)
{
System.err.println(u.getMessage());
}
catch(MalformedURLException u)
{
buf=u.getMessage();
}
catch (UnknownHostException u)
{
return false;
}
catch(SocketTimeoutException u)
{
return false;
}
catch(IOException u)
{
}
try
{
InputStream is = socket.getInputStream();
socket.setSoTimeout(3000);
try
{
OutputStream os= socket.getOutputStream();
try
{
os.write(getStr,0,tmpStr.length());
}
catch(IOException u)
{
}
}
catch(IOException u)
{
}
// R E A D
bytesRead = is.read( ba, 0 /* offset in ba */, ba.length /* bytes to read
*/ );
if (bytesRead!=-1)
{
System.out.println(bytesRead);
buf=new String(ba);
System.out.println(buf);
is.close();
}
}
catch(IOException u)
{
}
// C L O S E
try
{
socket.close();
}
catch(IOException u)
{
}
return true;
}
}