Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Applet notinited

 
Jkong Jkong
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey guys,

I'm a little new to the forum but trying to finish up an applet, and can't seem to get it to display. I get a gray box with a little red X up in the left hand corner. I'm running IE6 with swing enabled. The error message I get is attached below. I believe it has to do with my use of the exists() method of the File class from the package java.io. I have looked high and low and found little to nothing. Any idea how I can get my applet to work? I also forgot to mention that the directory "images" is in the same directory as in the class and holds jpg images for retrieval and display. There is no creating or writing files going on, only reading, which is why I'm so confused. I'm currently on Windows XP.

Java(TM) Plug-in: Version 1.4.2_05
Using JRE version 1.4.2_05 Java HotSpot(TM) Client VM
User home directory = C:\Documents and Settings\jkong

Proxy Configuration: No proxy





----------------------------------------------------
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 properties
t: dump thread list
v: dump thread stack
x: clear classloader cache
0-5: set trace level to <n>
----------------------------------------------------
java.security.AccessControlException: access denied (java.io.FilePermission images/SecureDoorLogo.jpg read)
at java.security.AccessControlContext.checkPermission(Unknown Source)
at java.security.AccessController.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkRead(Unknown Source)
at sun.awt.SunToolkit.getImageFromHash(Unknown Source)
at sun.awt.SunToolkit.getImage(Unknown Source)
at javax.swing.ImageIcon.<init>(Unknown Source)
at javax.swing.ImageIcon.<init>(Unknown Source)
at SecureDoorApplet.<init>(SecureDoorApplet.java:15)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(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)

-Jkong
[ November 05, 2004: Message edited by: Jkong Jkong ]
 
Jeff Bosch
Ranch Hand
Posts: 805
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you're trying to access a file through an applet you'll run into security exceptions. That seems to be the case here...
 
Jkong Jkong
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there no way around this?

a little about my applet. It's supposed to display a user's photo upon entry of his/her userID. The kicker is this, even if I take the image out of the images directory, and dump it into the same directory as the class file and the html file, I still run into the same security access exceptions. Is there no way around this? I've been reading online about signing an applet in order to allow it to access directories, but I have no idea how to do this. Any ideas to make it work?

-Jkong
 
Andrew Morrow
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In java, there are two commands you would need: keytool.exe and jarsigner.exe .

C:\>keytool.exe -genkey
Enter keystore password: xxxxxx
What is your first and last name?
[Unknown]: Andrew Morrow
What is the name of your organizational unit?
[Unknown]: Engineering
What is the name of your organization?
[Unknown]: My Company Inc.
What is the name of your City or Locality?
[Unknown]: Mountain View
What is the name of your State or Province?
[Unknown]: CA
What is the two-letter country code for this unit?
[Unknown]: US
Is CN=Andrew Morrow, OU=Engineering, O=My Company Inc., L=Mountain View, ST=CA,
C=US correct?
[no]: yes

Enter key password for <mykey> xxxxxx
(RETURN if same as keystore password):

C:\>


The default "alias" for this key is "mykey"


C:\>keytool.exe -list
Enter keystore password: andrew99

Keystore type: jks
Keystore provider: SUN

Your keystore contains 1 entry

mykey, Dec 6, 2004, keyEntry,
Certificate fingerprint (MD5): 94:B4:C6:28:99:09:FE:32:4C:1D:1F:C0:B1 9:78:1C

C:\>


Now you can sign your jar:


C:\>jarsigner.exe mytest.jar mykey
Enter Passphrase for keystore: xxxxxx

C:\>

Note that jarsigner.exe will add some files to the mytest.jar file, so rathern than just

META-INF/MANIFEST.MF

you now have

META-INF/MANIFEST.MF
META-INF/MYKEY.SF
META-INF/MYKEY.DSA
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic