Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

access denied 1

Status
Not open for further replies.

baum

Programmer
Aug 9, 2002
7
HK
I'm new to Java and I've written my first program. The program produced correct result. Then I put the program in an applet and loaded from a html page. The program runs too but when it's finished, I've found this message (in the applet area).

Exception: java.security.AccessControlException: access denied (java.lang.RuntimePermission exitVM)

Why did this happen and how to solves this? Thanks.
 
Your code called some method, that the browser's security did not allow you to call. When the code runs in a browser as an applet, security is more restricted. This is done to protect users systems.

 
To resolve your problem, we'll need to know what your program does, and if the program is not too long, the code.
For example, applets do not allow any kind of system file access ... see the java documentation on applet security.policy. Also the web browser that you are using would be helpful, as would the implementation and version of java that you are using. All these factors can contribute to runtime errors !

Ben
 
Thank you very much for help from jh from california and sedj. The program was written because of a question in a book: "Write an application that inputs from the user the radius of a circle and prints the circle's diameter, circumference and area." I think the problem is fixed, now when the applet is being loaded, the window status shows "Applet CircleApplet loaded" and after the applet has printed the circle's diameter, circumference and area, the window status shows "Applet CircleApplet started". I'm using Internet Explorer 6 and the Java version is 1.4.0. The applet code is as below:

import javax.swing.*;

public class CircleApplet extends JApplet {

public void init()
{
String radValue;
int radius;
int diameter;
double circumference;
double area;

radValue = JOptionPane.showInputDialog ( "Enter value of the radius" );

radius = Integer.parseInt( radValue );

diameter = 2 * radius;
circumference = 2 * Math.PI * radius;
area = Math.PI * radius * radius ;

JOptionPane.showMessageDialog(
null, "For a circle with radius " + radius
+ "\nThe diameter is " + diameter
+ "\nThe circumference is " + circumference
+ "\nThe area is " + area );

}

}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top