Solved

How: grant AllPermission to applet in Forte or Netbeans launched in appletviewer.exe by f6

Posted on 2002-07-18
2
807 Views
Last Modified: 2007-12-19
I have an applet that's ultimately intended to run as a signed applet via the 1.4 Java Plug-in (it requires access to the system clipboard and needs 1.4 because clipboard image transfers don't work with older versions).

Adding the "grant AllPermission" to "c:\program files\java\j2re1.4.0_01\lib\security\java.policy" made it run fine via the JPI under Internet Explorer from an object tag embedded in a html page and served via Forte's built-in Tomcat.

The problem is that I can't get it to run in appletviewer.exe if I launch it via f6 in Forte.

The applet's source code is in "d:\java\clipapplet", as are the compiled class files. I'm trying to grant AllPermission to any applet launched from d:\java and its subdirectories.

I tried to add the following grant directive to "c:\j2sdk1.4.0_01\jre\lib\security\java.policy" (NOTE -- not the same java.policy file as above):

grant codeBase "file:/D:/java/-" {
  permission java.security.AllPermission;
};

but it didn't make any difference. Launching the applet into appletviewer.exe via f6 still throws a security exception.

I'm not sure whether I'm adding the "grant" to the wrong file, using the wrong syntax, Forte itself is overriding/explicitly specifying a different properties file altogether, or perhaps Forte is launching the applet from a temp directory somewhere besides d:\java.

So... what, exactly, do I need to do to grant AllPermission to the applet when it runs in appletviewer when launched from Forte using f6?

Forte's ide.cfg file has the following line:
-jdkhome C:\j2sdk1.4.0_01 -J-Xmx96m -J-Xss1024k -J-Xms24m -J-Xverify:none
0
Comment
Question by:jskubick
2 Comments
 

Author Comment

by:jskubick
ID: 7165113
Well, after several hours of brute force experimentation, I managed to conclusively verify several things and ultimately solve the problem.

1. The relevant file WAS c:\j2sdk1.4.0_01\jre\lib\security\java.policy (corresponding to the -jdkhome parameter in forte's ide.cfg file).

2. The policy file IS consulted each time appletviewer launches an applet. In other words, it's NOT read one time and cached until the next system restart.

These two conclusions were actually confirmed by a typo I made in the java.policy file that resulted in the display of an error message in Forte's output window when launching the applet for the Nth time.

3. This is the big one. Appletviewer sees the applet as having been accessed via http from the local machine, but the following URLs will NOT match as codeBase parameters:

http://localhost/-
http://127.0.0.1/-
http://-

So what's the RIGHT answer? If you're running Windows XP (and presumably Win2k), it's your machine's "full computer name" (right click "My Computer", choose "properties", then go to "Computer Name". In my case, the value there is "jeff.", so the following codeBase parameter ultimately worked:

grant codeBase "http://jeff/-"

Grrrrr.
0
 
LVL 1

Accepted Solution

by:
Computer101 earned 0 total points
ID: 7165230
Points refunded and placed in PAQ

Computer101
E-E Moderator
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to get all the API from website? 11 86
servlet doXXX methods 3 49
arguments to jar 5 26
ejb on wildfly 5 19
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question