Hello -
The
java file (this version has code that requires signing commented out - at this point I am just trying to get a jar'd class file to work.)
import java.applet.Applet;
import java.awt.Graphics;
import java.io.*;
import java.awt.Color;
/**
*
* A simple Signed
Applet Demo
*
*/
public class SignedAppletDemo extends Applet {
public
String test() {
setBackground(Color.white);
//String fileName = System.getProperty("user.home") +
// System.getProperty("file.separator") +
// "newfile";
String fileName = "c:\\java\\newfile";
String msg = "This message was written by a signed applet!!!\n";
String s ;
try {
//FileWriter fos = new FileWriter(fileName);
//fos.write(msg, 0, msg.length());
//fos.close();
s = new String("Successfully created file (not) :" + fileName);
} catch (Exception e) {
System.out.println("Exception e = " + e);
e.printStackTrace();
s = new String("Unable to create file : " + fileName);
}
return s;
}
public void paint(Graphics g) {
g.setColor(Color.blue);
g.drawString("Signed Applet Demo", 120, 50);
g.setColor(Color.magenta);
g.drawString(test(), 50, 100);
System.out.println("hello2");
}
}
I put this into a jar file with the commands -
javac SignedAppletDemo.java
jar cvf SignedAppletDemo.jar SignedAppletDemo.class
The html file -----
<html>
<head>
</head>
<body>
<applet code=SignedAppletDemo.class archive="SignedAppletDemo.jar"
width=100 height=100>
</applet>
</body>
</html>
The jar and html files are in the same folder.
When I run this on my machine (double clicking the html file in Explorer, which starts Chrome) it works fine. When I put these two files in the same directory on the web (
http://www.mathcarpenter.com/demo.html ) and navigate there with Chrome, I get a "class not found" error on SignedAppletDemo.class .
The jar file looks like this -
c:\Users\John\workspace2\documentsClient\src>jar tvf SignedAppletDemo.jar
0 Tue Aug 09 23:14:28 CDT 2011 META-INF/
71 Tue Aug 09 23:14:28 CDT 2011 META-INF/MANIFEST.MF
1460 Tue Aug 09 23:14:28 CDT 2011 SignedAppletDemo.class
The manifest file looks like this -
Manifest-Version: 1.0
Created-By: 1.6.0_26 (Sun Microsystems Inc.)
What am I missing?