File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Applets and the fly likes First time applet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Applets
Bookmark "First time applet" Watch "First time applet" New topic
Author

First time applet

Joe Meany
Greenhorn

Joined: Jun 14, 2011
Posts: 25
Hey there guys,

I am in the process of the creating my first applet . I have run into a problem though. I can run the applet through eclipse and the applet viewer pops up, says applet loaded, and my program starts(this was initially an application i have been transferring to applet). When it loads from eclipse, it connects, selects, inserts, and deletes to the database perfectly. However, and this could definitely be from me doing something incredibly basic wrong, when i run it through a html file i made with a reference to appletName.class, the browser window pops up, and nothing else.

I did however right click on the java icon and pulled up this error from the log:
Exception: java.security.AccessControlException: access denied (java.util.PropertyPermission file.encoding read)

Now obviously that isnt the whole error log, but it seemed like it was the most important. It appears to me, that it has something to do with my MySql database connecting. I did look up some information online, and many suggest to update my .policy file. Now, i don't know if this is a good idea or not, but i really have no clue what it means in the first place.

Any help with this would be really helpful, and i would truly appreciate it.
Also, i have hopes of running this off a a server for the place i work at, in order to allow everyone to have access through the browser by typing in something like- ip:port:file.

Thanks again, if anyone is willing to help and would like some more information ( i didnt really know what was all- too important, and all-not, as im not familiar with applets) i will do so asap.

Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41629
    
  55
Applets are not allowed to do a number of things, including file I/O and various networking tasks; it would seem that your applet is trying to do one of these. You may need to sign it: http://www.coderanch.com/how-to/java/HowCanAnAppletReadFilesOnTheLocalFileSystem


Ping & DNS - my free Android networking tools app
Joe Meany
Greenhorn

Joined: Jun 14, 2011
Posts: 25
Thank you very much! I tried looking around, but because I didnt really know what was going on, it was hard to find any answers.

Thanks for the great link!
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

I would have used "applet access denied" for my Google keywords, and I'm pretty good at finding things on the web. Was that anything like what you tried?
Joe Meany
Greenhorn

Joined: Jun 14, 2011
Posts: 25
No, i just typed in the error message..and i got results. Well, i got peoples suggestions, but i couldnt find what it really meant. that above link is very informative, but i hadnt realized this process was so complicated
Joe Meany
Greenhorn

Joined: Jun 14, 2011
Posts: 25
Ok, so i am still having some trouble with this and was hoping for a bit more direction(sorry).
Now, when i run my applet through google chrome, i get a bar at the top that says it needs my permission to run, i allow it, but nothing happens. I opened up the console again to see the same error message, ill post the whole thing now:


If anyone has any suggestions i would greatly appreciate it. I am not sure if my certificates are working right. I followed the links above, but there were some situations where it got a little hairy, and i wasnt sure of what the tutorial wanted me to do. I also was looking up how to have a policy file allow for all permissions but i don't want to play with something i am unsure of.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41629
    
  55
Don't go the policy file route - you can't expect random users of your applet to be able or willing to fiddle around with those.

Yes, it looks like the applet code is not signed correctly (or at all), or possibly the code in question needs to be run as privileged code (also described in the link I posted earlier).
Joe Meany
Greenhorn

Joined: Jun 14, 2011
Posts: 25
Oops, i hid my console window on accident. Alright, thank you for all of your responses Ulf, really appreciated.
Joe Meany
Greenhorn

Joined: Jun 14, 2011
Posts: 25
Hey there,

Sorry to keep adding to this thread.. but im still having one heck of a time with this.

So, ill start from the beginning:
1)exported jar
2)signed jar
3)created certificate
4) Doesnt work

Browsers on other machines dont even prompt for certificate authentication...they just error out in the console again(same error as before)
So, im really not so sure what is wrong with this anymore. From what ive read online, if i self-sign my applet... dont i have to import that certificate onto everyones machine who will be running this?

Is there a good way to do what i want to do other than with an applet(maybe throwing it on an application server?)

Again, i apologize i am pretty new to applets... but i would love to see this work.

Any suggestions(or pointers at what i am probably doing wrong) would be great! thank you!
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41629
    
  55
1)exported jar
2)signed jar
3)created certificate

How can you sign anything before creating a certificate? How are you using the keytool and jarsigner tools?

From what ive read online, if i self-sign my applet... dont i have to import that certificate onto everyones machine who will be running this?

No. The certificate is part of the signed jar files.
Joe Meany
Greenhorn

Joined: Jun 14, 2011
Posts: 25
ok, im sorry about that, let me bring up the "applet signing tutorial" i was looking at and do this better....

alright:

1) package applet into jar file(using eclipse)
2)create a pblic/private key pair using: keytool-genkey
3)create a certificate using: keytool -selfcert
4)run jarsigner -keystore jarFile.jar key

I *think* this is how i am supposed to do it. Sorry if my explanation was rash.

And thanks again for your help with this. Youre pretty super.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: First time applet