Access denied ("java.io.FilePermission" "execute")
I start. This is the first applet I write
I want to run an exe application with an applet
java code
package appletexample;
import java.io.*;
import java.awt.*;
import java.applet.Applet;
public class Welcome extends Applet {
public void init() {
String execommand = "C:\\windows\\notepad.exe" ;
try {
Process proc = Runtime.getRuntime().exec(execommand) ;
}
catch(IOException ieo) {
System.out.println("Problem starting " + execommand) ;
}
}
}
java.policy.applet
grant {
permission java.security.AllPermission;
};
I ran this code in eclipse it Run As->Java Applet
worked and opened NotePade but when Export->Jar File(with .classPath,.project,java.policy.applet)
and use in
Html
<applet archive="test.jar" code="appletexample/Welcome.class" width=550 height=300>
in firefox say error access is denied ("java.io.FilePermission" "execute")? How to solve this problem? download my java and html
source to share
I am assuming you just want to learn how to write an applet. For development purposes, you can create a keystore and then use that to sign your applet.jar.
Go: Start Menu> Run> cmd.exe
Entrance:
cd /
keytool -genkey -dname "cn=CN, ou=OU, o=O, l=L, st=ST, c=C" -alias mykey -keypass mypass -keystore mystore -validity 3650 -storepass mypass
jarsigner -keystore c:\mystore -storepass mypass C:\path\to\applet.jar mykey
Then:
Refresh HTML page.
source to share
As a beginner, you should start with something much simpler. When you play with applets, not all safety rules apply. But when you come into the real world (a browser in your case, or in other words, a sandbox), there are security rules to keep your code from harming the host computer.
What you are doing is you are running some program on the client computer when the client opens your web page using an applet. This is what viruses do. People won't want to let this happen.
Of course, you can use a Signed Applet or other ways to run the program on another computer, but is that your purpose? If you need to learn the basics, then run the easy material. Eventually, you will understand JNLP (Java Web Start) and other techniques that are useful to you and your clients.
source to share