Получение SecurityException: Отказано в разрешении в Java - PullRequest
0 голосов
/ 15 февраля 2012

Я получаю java.lang.SecurityException: Permission denied: file:////Videos/public/scripts/screenshot.jar, когда пытаюсь использовать апплет.

Вот код апплета:

<applet code="Screenshot" archive="file:////Videos/public/scripts/screenshot.jar" width="100px" height="100px">
</applet>

Как это исправить и что вообще означает проблема?

EDIT:

Из того, что я вижу, мне нужно подписать апплет. Может кто-нибудь объяснить, как и почему это делается? Предоставленный сайт делает плохую работу, объясняя это, потому что он даже не учитывает тот факт, что я встраиваю это в свой сайт и хочу, чтобы каждый клиент использовал его и не должен был подписывать что-либо. Просто нажмите Run.

EDIT2:

Код самого приложения:

/*
By Bavo Bruylandt (Http://www.realapplets.com")

*/

// and now The inevidable "Hello World" example :)

// tell the compiler where to find the methods you will use.
// required when you create an applet
import java.applet.*;
// required to paint on screen
import java.awt.*;


// the start of an applet - HelloWorld will be the executable class
// Extends applet means that you will build the code on the standard Applet class
public class Screenshot extends Applet
{

// The method that will be automatically called  when the applet is started
     public void init()
     {
 // It is required but does not need anything.
     }


// This method gets called when the applet is terminated
// That's when the user goes to another page or exits the browser.
     public void stop()
     {
     // no actions needed here now.
     }


// The standard method that you have to use to paint things on screen
// This overrides the empty Applet method, you can't called it "display" for example.

     public void paint(Graphics g)
     {
 //method to draw text on screen
 // String first, then x and y coordinate.
      g.drawString("Hey hey hey",20,20);
      g.drawString("Hellooow World",20,40);

     }

} 

1 Ответ

0 голосов
/ 15 февраля 2012

Все зависит от того, что пытается сделать ваш апплет, например, обращается ли он к файловой системе. Это подписанный апплет или нет? Апплеты запускаются в специальной песочнице по умолчанию с ограниченными разрешениями. Вы должны были бы проверить больше информации о безопасности Апплета, для начала посмотрите статью Informit здесь: http://www.informit.com/articles/article.aspx?p=433382&seqNum=2

EDIT:

Попробуйте добавить файл политики, например.

/* AUTOMATICALLY GENERATED ON Tue Apr 16 17:20:59 EDT 2002*/
  /* DO NOT EDIT */

   grant {
     permission java.security.AllPermission;
   };

назван например. java.policy.applet и поместите его в свой путь к классам. Посмотрите на этот вопрос здесь о файлах политики: Где разместить файл политики Java-апплета?

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...