Sign Applet fail

Hello, I developed my code in NetBeans 5.51 plus Java 1.5.

By signing the JAR file under Java 1.5, I can't open the applet.

The console's message is failing reading file. But if I sign it with Java 1.6 with the same JAR file, it successes.Why?

I have to use Java 1.5 for my case.

Thanks!

[320 byte] By [ardmorea] at [2007-11-27 11:57:15]
# 1

My whole process is

C:\Program Files\Java\jdk1.5.0_12\bin>keytool -genkey -keystore c:\mykeystore -a

lias myself

Enter keystore password: 888888

What is your first and last name?

[Unknown]: aaaaa

What is the name of your organizational unit?

[Unknown]: aaaaa

What is the name of your organization?

[Unknown]: aaaaa

What is the name of your City or Locality?

[Unknown]: aaaaa

What is the name of your State or Province?

[Unknown]: aa

What is the two-letter country code for this unit?

[Unknown]: us

Is CN=aaaaa, OU=aaaaa, O=aaaaa, L=aaaaa, ST=aa, C=us correct?

[no]: y

Enter key password for <myself>

(RETURN if same as keystore password):

C:\Program Files\Java\jdk1.5.0_12\bin>keytool -selfcert -alias myself -keystore

c:\mykeystore

Enter keystore password: 888888

C:\Program Files\Java\jdk1.5.0_12\bin>keytool -list -keystore c:\mykeystore

Enter keystore password: 888888

Keystore type: jks

Keystore provider: SUN

Your keystore contains 1 entry

myself, Jul 27, 2007, keyEntry,

Certificate fingerprint (MD5): B3:F0:B8:D0:11:DC:E1:D3:EF:B3:3B:38:86:EC:28:77

C:\Program Files\Java\jdk1.5.0_12\bin>jarsigner -keystore c:\mykeystore c:\TestC

ell4.1.jar myself

Enter Passphrase for keystore: 888888

Warning: The signer certificate will expire within six months.

C:\Program Files\Java\jdk1.5.0_12\bin>

ardmorea at 2007-7-29 19:12:17 > top of Java-index,Java Essentials,New To Java...
# 2

> The console's message is failing reading file

Don't paraphrase error messages, post full and complete copies of all of the related text.

You haven't given any useful information.

ChuckBinga at 2007-7-29 19:12:17 > top of Java-index,Java Essentials,New To Java...
# 3

**Error: larger_plotdata.bin (The system cannot find the file specified)

java.lang.reflect.InvocationTargetException

at java.awt.EventQueue.invokeAndWait(EventQueue.java:853)

at Combox.init(Combox.java:55)

at Combox.main(Combox.java:301)

Caused by: java.lang.NullPointerException

at javax.swing.DefaultComboBoxModel.<init>(DefaultComboBoxModel.java:53)

at javax.swing.JComboBox.<init>(JComboBox.java:177)

at Combox.initComponents(Combox.java:94)

at Combox.access$000(Combox.java:28)

at Combox$1.run(Combox.java:57)

at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:199)

at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)

at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchTh

read.java:242)

at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThre

ad.java:163)

at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)

at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)

at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)

ardmorea at 2007-7-29 19:12:17 > top of Java-index,Java Essentials,New To Java...
# 4

The first line is telling you that a file is missing or mislocated or it's location is not correctly specified:

**Error: larger_plotdata.bin (The system cannot find the file specified)

ChuckBinga at 2007-7-29 19:12:17 > top of Java-index,Java Essentials,New To Java...
# 5

well, it's strange.

It is ok for Java 1.6.

I just right click the project code,it automately create the JAR file.

NetBeans has such a function.

ardmorea at 2007-7-29 19:12:17 > top of Java-index,Java Essentials,New To Java...
# 6

> well, it's strange.

> It is ok for Java 1.6.

> I just right click the project code,it automately

> create the JAR file.

> NetBeans has such a function.

But you don't get that message when you're creating the jar file. You get it when you're running something. So you need to examine your code and find out where it's trying to read that file, and then find out what assumptions your code is making.

Generally my advice to people who are writing signed applets to access files on the client's system is this: if you can't debug basic problems like the one you're having, you shouldn't be writing signed applets just yet. Step back and write some basic Java applications and learn the ropes before you start on advanced techniques.

DrClapa at 2007-7-29 19:12:17 > top of Java-index,Java Essentials,New To Java...
# 7

one more question.

Do I need to do both things which is to modify a policy file and sign an applet or just either way?

Thanks

ardmorea at 2007-7-29 19:12:17 > top of Java-index,Java Essentials,New To Java...
# 8

> one more question.

> Do I need to do both things which is to modify a

> policy file and sign an applet or just either way?

>

> Thanks

If you sign an applet, it can work on any client computer if the operatoe accepts the applet's certificate.

If you place an appropriately configured policy file on a computer, it allows an applet to execute on that computer only.

ChuckBinga at 2007-7-29 19:12:17 > top of Java-index,Java Essentials,New To Java...