Duvida basica

3 respostas
M

ola pessoal, estou tentando acessar um arquivo .txt via java web start, para edita-lo …
mas quando executo, da o seguinte erro :

Exception in thread AWT-EventQueue-0 java.security.AccessControlException: access denied (java.io.FilePermission arquivo.txt read)

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.checkRead(Unknown Source)

at java.io.RandomAccessFile.<init>(Unknown Source)

at _escreverAA.<init>(_escreverAA.java:12)

at Acesso$1.actionPerformed(Acesso.java:23)

at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)

at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)

at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)

at javax.swing.DefaultButtonModel.setPressed(Unknown Source)

at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)

at java.awt.Component.processMouseEvent(Unknown Source)

at javax.swing.JComponent.processMouseEvent(Unknown Source)

at java.awt.Component.processEvent(Unknown Source)

at java.awt.Container.processEvent(Unknown Source)

at java.awt.Component.dispatchEventImpl(Unknown Source)

at java.awt.Container.dispatchEventImpl(Unknown Source)

at java.awt.Component.dispatchEvent(Unknown Source)

at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)

at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)

at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)

at java.awt.Container.dispatchEventImpl(Unknown Source)

at java.awt.Window.dispatchEventImpl(Unknown Source)

at java.awt.Component.dispatchEvent(Unknown Source)

at java.awt.EventQueue.dispatchEvent(Unknown Source)

at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)

at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)

at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)

at java.awt.EventDispatchThread.pumpEvents(Unknown Source)

at java.awt.EventDispatchThread.pumpEvents(Unknown Source)

at java.awt.EventDispatchThread.run(Unknown Source)

segue meu codigo (quando executo pelo eclipse funciona, qunado crio o .jar e clico 2 vezes, tambem, so nao funciona na web … ) :

import java.io.*;
import javax.swing.JOptionPane;

public class _navegarAA {

private static RandomAccessFile arquivo;

public _navegarAA() {

try {

arquivo = new RandomAccessFile(new File(arquivo.txt), rw);

JOptionPane.showMessageDialog(null, acho arquivo, “”, JOptionPane.ERROR_MESSAGE);

} catch (FileNotFoundException e) {

JOptionPane.showMessageDialog(null, e.getMessage(), erro 1 nao acho, JOptionPane.ERROR_MESSAGE);

}
try {

arquivo.seek(0);

arquivo.seek(12);

JOptionPane.showMessageDialog(null, leo arquivo, “”, JOptionPane.ERROR_MESSAGE);

} catch (IOException e) {

JOptionPane.showMessageDialog(null, e.getMessage(), erro 2 nao leo, JOptionPane.ERROR_MESSAGE);

}
try {

arquivo.seek(12);

arquivo.writeChar(X);

arquivo.seek(12);

JOptionPane.showMessageDialog(null, navego arquivo, “”, JOptionPane.ERROR_MESSAGE);

} catch (IOException e) {

JOptionPane.showMessageDialog(null, e.getMessage(), erro 2 nao navego, JOptionPane.ERROR_MESSAGE);

}

}

}

3 Respostas

BrunoBastosPJ

Vou chutar… Você não tem que assinar seu programa? Se não me engano você tem que permitir que o programa crie um arquivo na máquina do usuário. Nunca trabalhei com WS por isso é um chute

Abs

F

Olá!

http://www.inf.ufrgs.br/procpar/disc/inf01008/trabalhos/sem01-1/t1/javaws/

M

o meu jar esta assinado e nao consigo acesso …

Criado 25 de junho de 2007
Ultima resposta 26 de jun. de 2007
Respostas 3
Participantes 3