I'm trying to run this simple HelloWorld code written in Java from my browser (Chrome):
public class HelloWorld extends JApplet {
public void init() {
try {
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
JLabel lbl = new JLabel("Hello World");
add(lbl);
}
});
}
catch (Exception e) {
System.err.println("createGUI didn't complete successfully");
}
}
I compiled it with NetBeans, and then I created a WebApplication project. The HTML code that runs the applet is:
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p><applet code="HelloWorld" archive="applet_HelloWorld.jar" width="590" height="530"></applet></p>
</body>
</html>
If run the applet from NetBeans it works. But when I run the HTML code by double clicking it, the following message pops up from the browser:
Your security settings have blocked a local application from running.
I tried with Internet Explorer and Firefox but nothing.
This message started to appear after the last update of Java. Where is the problem?
My problem case was to run portecle.jnlp file locally using Java8.
What worked for me was
On step 3, you might try also to add file:///c:/path/portecle.jnlp, but this addition didn't help with my case.
Java applets do create a security risk, hence are disabled in most modern browsers. You have to lower the security to run it. There is a guide by Oracle for that.
If you have no Medium security level, then you should add your application to the Exception Site List (Java Control Panel → Security tab).
Go to Control Panel → Java Control Panel → Security tab and press the Edit Site List... button.
Press the Add button, insert your path and press Enter.
Press Continue on the security warning that appears.
Open the applet again and don't forget to press Run on the pop-up window.