Whenever I try accessing the appdata folder from my applet it gives me the following error:
Any help?Code :java.io.FileNotFoundException: C:\users\<user name>\AppData\Roaming\test\test.class (Access is denied)
Printable View
Whenever I try accessing the appdata folder from my applet it gives me the following error:
Any help?Code :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?
The problem is it even gives the error when in applet simulator.
What is the applet simulator?
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.Quote:
sign your jar. I'm wondering how you do that.
See the tutorial: http://docs.oracle.com/javase/tutori...tFunction.html
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?
It just shows a white square for my applet when I run it in a webpage.
what is the "it"?Quote:
it keeps giving me this error
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?
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.
I can't find the button.
Where did you look?
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.
On what browser?
Chrome and Firefox
It said:
Quote:
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.Quote:
<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>
The applet does not have the permission it needs.Quote:
java.security.AccessControlException: access denied ("java.util.PropertyPermission" "user.name" "read")
I've never used JNLP. I've only used the <applet tags.
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.Quote:
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";
};
So you add that to your applet?