Whenever I try accessing the appdata folder from my applet it gives me the following error:
Any help?java.io.FileNotFoundException: C:\users\<user name>\AppData\Roaming\test\test.class (Access is denied)
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
Whenever I try accessing the appdata folder from my applet it gives me the following error:
Any help?java.io.FileNotFoundException: C:\users\<user name>\AppData\Roaming\test\test.class (Access is denied)
Applets are not allowed to access files on the machine it is executing on.
They can get files from the server they were loaded from.
Can you explain in more detail what you are trying to do?
If you don't understand my answer, don't ignore it, ask a question.
The problem is it even gives the error when in applet simulator.
What is the applet simulator?
If you don't understand my answer, don't ignore it, ask a question.
I meant the applet viewer in eclipse.
--- Update ---
Also, I have heard that you have to sign your jar. I'm wondering how you do that.
Ask google. Signing a jar is a multi-step process.sign your jar. I'm wondering how you do that.
See the tutorial: http://docs.oracle.com/javase/tutori...tFunction.html
If you don't understand my answer, don't ignore it, ask a question.
ajayajayaj (February 20th, 2013)
Thanks, but it still gives me the access denied error.
You were able to sign the jar file in 20 minutes?
How do you use a jar file with AppletViewer?
If you don't understand my answer, don't ignore it, ask a question.
It just shows a white square for my applet when I run it in a webpage.
what is the "it"?it keeps giving me this error
If you don't understand my answer, don't ignore it, ask a question.
Sorry, I mean it just shows a white square for my applet when I run it in a webpage.
What is shown in the browser's java console?
If you don't understand my answer, don't ignore it, ask a question.
How do you get that?
I'm on Google chrome by the way.
There is a setting via the Java icon in the Control Panel on Windows.
If you don't understand my answer, don't ignore it, ask a question.
I can't find the button.
Where did you look?
If you don't understand my answer, don't ignore it, ask a question.
Well, I selected Advanced Then selected show console.
But where is the cosole?
Mine comes in the upper left of the screen when I open a page with an applet.
If you don't understand my answer, don't ignore it, ask a question.
On what browser?
Chrome and Firefox
If you don't understand my answer, don't ignore it, ask a question.
It said:
Java Plug-in 10.15.2.03
Using JRE version 1.7.0_15-b03 Java HotSpot(TM) Client VM
User home directory = C:\Users\Ajay
----------------------------------------------------
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
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>
----------------------------------------------------
Exception in thread "AWT-EventQueue-2" java.security.AccessControlException: access denied ("java.util.PropertyPermission" "user.name" "read")
at java.security.AccessControlContext.checkPermission (Unknown Source)
at java.security.AccessController.checkPermission(Unk nown Source)
at java.lang.SecurityManager.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPropertyAccess(Unkn own Source)
at java.lang.System.getProperty(Unknown Source)
at Main.run(Main.java:96)
at Main.paint(Main.java:59)
at javax.swing.JComponent.paintChildren(Unknown Source)
at javax.swing.JComponent.paint(Unknown Source)
at javax.swing.JLayeredPane.paint(Unknown Source)
at javax.swing.JComponent.paintChildren(Unknown Source)
at javax.swing.JComponent.paintToOffscreen(Unknown Source)
at javax.swing.RepaintManager$PaintManager.paintDoubl eBuffered(Unknown Source)
at javax.swing.RepaintManager$PaintManager.paint(Unkn own Source)
at javax.swing.RepaintManager.paint(Unknown Source)
at javax.swing.JComponent.paint(Unknown Source)
at java.awt.GraphicsCallback$PaintCallback.run(Unknow n Source)
at sun.awt.SunGraphicsCallback.runOneComponent(Unknow n Source)
at sun.awt.SunGraphicsCallback.runComponents(Unknown Source)
at java.awt.Container.paint(Unknown Source)
at javax.swing.RepaintManager$3.run(Unknown Source)
at javax.swing.RepaintManager$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPri vilege(Unknown Source)
at javax.swing.RepaintManager.paintDirtyRegions(Unkno wn Source)
at javax.swing.RepaintManager.paintDirtyRegions(Unkno wn Source)
at javax.swing.RepaintManager.prePaintDirtyRegions(Un known Source)
at javax.swing.RepaintManager.access$1000(Unknown Source)
at javax.swing.RepaintManager$ProcessingRunnable.run( Unknown Source)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$200(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPri vilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilter s(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(U nknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarch y(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Repeats...
--- Update ---
Also, what I understood from the link you gave me was you have to add the text:
to run the applet instead of the normal code.<script src=
"http://www.java.com/js/deployJava.js"></script>
<script>
var attributes = {code:'<whatever>.class',
archive:'<whatever.jar>.jar',
width:710, height:540} ;
var parameters = {fontSize:16} ;
var version = '1.7' ;
deployJava.runApplet(attributes, parameters, version);
</script>
Last edited by ajayajayaj; February 21st, 2013 at 08:05 PM. Reason: Repeats
The applet does not have the permission it needs.java.security.AccessControlException: access denied ("java.util.PropertyPermission" "user.name" "read")
I've never used JNLP. I've only used the <applet tags.
If you don't understand my answer, don't ignore it, ask a question.
So how do you give it the permission?
My applets that require permission are only executed on my pc. I use the .java.policy file to grant permissions.
Here is a sample of my .java.policy file:I use the policytool to edit it. It is located in the user.dir folder.
grant {
permission java.lang.RuntimePermission "modifyThread";
permission java.lang.RuntimePermission "loadLibrary.HelloNative";
permission java.util.PropertyPermission "*", "read";
permission java.lang.RuntimePermission "modifyThreadGroup";
permission java.io.FilePermission "E:/Java/Java-1_6_0/docs", "read";
permission java.io.FilePermission "E:/Java/tutorial", "read";
permission java.net.SocketPermission "127.0.0.1:3000", "connect, resolve";
};
grant codeBase "file:/D:/JavaDevelopment/Testing/WriteFile/-" {
permission java.io.FilePermission "D:/Testing/*", "read, write";
};
If you don't understand my answer, don't ignore it, ask a question.
So you add that to your applet?