T
toef82
Gast
Moin, Ich habe einen simplen Counter als Applet geschrieben, der einfach die Besucher der Seite Zählen soll,wo das Applet mit eingebunden ist.Der aktuelle Zählerwert wird in einer textdatei gespeicher(count.txt),eingelesen,um eins hochgezählt,zurück geschrieben und ausgegeben.
Aber ich erhalte nun immer diese Fehlermeldung
java.security.AccessControlException: access denied (java.io.FilePermission 346 write)
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.checkWrite(Unknown Source)
at java.io.FileOutputStream.<init>(Unknown Source)
at java.io.FileOutputStream.<init>(Unknown Source)
at java.io.FileWriter.<init>(Unknown Source)
at ConterMain.schreiben(ConterMain.java:32)
at ConterMain.init(ConterMain.java:54)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Ausnahme: java.security.AccessControlException: access denied (java.io.FilePermission 346 write)
java.security.AccessControlException: access denied (java.io.FilePermission 346 write)
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.checkWrite(Unknown Source)
at java.io.FileOutputStream.<init>(Unknown Source)
at java.io.FileOutputStream.<init>(Unknown Source)
at java.io.FileWriter.<init>(Unknown Source)
at ConterMain.schreiben(ConterMain.java:32)
at ConterMain.init(ConterMain.java:54)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Ausnahme: java.security.AccessControlException: access denied (java.io.FilePermission 346 write)
java.security.AccessControlException: access denied (java.io.FilePermission 346 write)
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.checkWrite(Unknown Source)
at java.io.FileOutputStream.<init>(Unknown Source)
at java.io.FileOutputStream.<init>(Unknown Source)
at java.io.FileWriter.<init>(Unknown Source)
at ConterMain.schreiben(ConterMain.java:32)
at ConterMain.init(ConterMain.java:54)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Ausnahme: java.security.AccessControlException: access denied (java.io.FilePermission 346 write)
Der Applet Code ist wie folgt:
die html datei(index.htm) enthält
<html>
<head>
<title>Formular-Überprüfung</title>
</head>
<body>
<h1>Besucher insgesamt</h1>
<applet code="ConterMain.class" width=400 heigth=10>
</applet>
</body>
</html>
In der count.txt steht nur die zahl 345
alle 3 Dateien habe ich in einen Ordner unter c:\temp abgelegt(ConterMain.class;count.txt und index.html)
Ich komme echt nicht weiter und die anderen Threads haben mir auch nicht geholfen.. weiss jemand wie man dieses Problem in den Griff bekommt?
Aber ich erhalte nun immer diese Fehlermeldung
java.security.AccessControlException: access denied (java.io.FilePermission 346 write)
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.checkWrite(Unknown Source)
at java.io.FileOutputStream.<init>(Unknown Source)
at java.io.FileOutputStream.<init>(Unknown Source)
at java.io.FileWriter.<init>(Unknown Source)
at ConterMain.schreiben(ConterMain.java:32)
at ConterMain.init(ConterMain.java:54)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Ausnahme: java.security.AccessControlException: access denied (java.io.FilePermission 346 write)
java.security.AccessControlException: access denied (java.io.FilePermission 346 write)
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.checkWrite(Unknown Source)
at java.io.FileOutputStream.<init>(Unknown Source)
at java.io.FileOutputStream.<init>(Unknown Source)
at java.io.FileWriter.<init>(Unknown Source)
at ConterMain.schreiben(ConterMain.java:32)
at ConterMain.init(ConterMain.java:54)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Ausnahme: java.security.AccessControlException: access denied (java.io.FilePermission 346 write)
java.security.AccessControlException: access denied (java.io.FilePermission 346 write)
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.checkWrite(Unknown Source)
at java.io.FileOutputStream.<init>(Unknown Source)
at java.io.FileOutputStream.<init>(Unknown Source)
at java.io.FileWriter.<init>(Unknown Source)
at ConterMain.schreiben(ConterMain.java:32)
at ConterMain.init(ConterMain.java:54)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Ausnahme: java.security.AccessControlException: access denied (java.io.FilePermission 346 write)
Der Applet Code ist wie folgt:
Java:
import java.applet.Applet;
import java.awt.Graphics;
import java.io.*;
public class ConterMain extends Applet {
int count=0;
String temp="";
private static final long serialVersionUID = 1L;
public static String lesen(String dateiname)throws FileNotFoundException,IOException{
BufferedReader in=new BufferedReader(new FileReader(dateiname));
StringBuffer inputstr = new StringBuffer("");
String line= new String();
line= in.readLine();
while(line!=null){
inputstr=inputstr.append(line);
line= in.readLine();
}
in.close();
return inputstr.toString();
}
public void schreiben(String dateiname,String s)throws IOException{
PrintWriter out;
out = new PrintWriter(new FileWriter(dateiname));
out.print(s);
out.close();
}
public void init(){
try {
temp=lesen("C://temp//count.txt");
System.out.print(temp);
count= Integer.parseInt(temp);
} catch (NumberFormatException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
count=count+1;
try {
schreiben(String.valueOf(count),"count.txt");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public void paint(Graphics g){
g.drawString(String.valueOf(count), 10, 10);
}
}
die html datei(index.htm) enthält
<html>
<head>
<title>Formular-Überprüfung</title>
</head>
<body>
<h1>Besucher insgesamt</h1>
<applet code="ConterMain.class" width=400 heigth=10>
</applet>
</body>
</html>
In der count.txt steht nur die zahl 345
alle 3 Dateien habe ich in einen Ordner unter c:\temp abgelegt(ConterMain.class;count.txt und index.html)
Ich komme echt nicht weiter und die anderen Threads haben mir auch nicht geholfen.. weiss jemand wie man dieses Problem in den Griff bekommt?