Reputation: 3027
I have a simple test applet that's supposed to draw a little triangle (and works fine using appletviewer Triangle.class
from the command line), but when I try to view Triangle.htm
in my browser, I get this message (from Java itself, as far as I can tell, not my Firefox or Chrome):
"Your security settings have blocked a local application from running."
However, I can't figure out what settings to change. I tried just putting the general settings at their lowest (called "medium" ha ha what is this like cup sizes in a coffee shop-- Oh. Right.) but that didn't work, and if the solution is buried somewhere in the more advanced options, it's painfully non-obvious to me... :/
This question sounded like my problem:
Java Error: "Your security settings have blocked a local application from running"
But the original poster said, "Resolved: the problem was that the compiler used JDK6 instead of JDK7."
And I checked I had the latest version before re-compiling the class file:
> java -version
java version "1.7.0_25"
Java(TM) SE Runtime Environment (build 1.7.0_25-b17)
Java HotSpot(TM) Client VM (build 23.25-b01, mixed mode, sharing)
> javac Triangle.java
Anyway, can anyone see if they get the same problem and tell me how you fix it?
For easy replication, this is the source of the class file:
Triangle.java
:
import java.awt.*;
import java.applet.Applet;
public class Triangle extends Applet {
public void paint (Graphics g){
int bottomX=80;
int bottomY=200;
int base=100;
int height=100;
g.drawLine(bottomX,bottomY,bottomX+base,bottomY);
g.drawLine(bottomX+base,bottomY,bottomX+base/2,bottomY-height);
g.drawLine(bottomX+base/2,bottomY-height, bottomX,bottomY);
}
}
And this is the htm that's in the folder with the class file:
Triangle.htm
:
<applet code="Triangle.class" width=400 height=400></applet>
Upvotes: 3
Views: 20358
Reputation: 168845
I just tried your code using Java version 1.7.0_25-b17. It works just fine in the browser on the two lower settings seen here.
To get it to work for the highest security level, it needs to be put in a Jar and signed using a valid certificate.
Upvotes: 4
Reputation: 2672
It was officially stated (Oracle's response to my school-team's email) that some older remains of virtual machines may actually cause security alerts with applets even if you set security settings to absolute minimum (had it many times with my applet). I guess it is a school/study work (as it is an applet), so it is probably worth trying to run it directly by appletviewer.
Upvotes: 0