![Firefox logo](https://assets-prod.sumo.prod.webservices.mozgcp.net/media/uploads/products/2020-04-14-08-36-13-8dda6f.png)
Java Applets don't run correctly on Mac any more. On Windows everything is correct. 3 months ago it was also working perfect with mac.
I call a Java class from JavaScript in HTML-Code. The JavaScript get loaded earlier then the Java Applet. Even the Java Applet-Tag is on the top. When I have a button in HTML to start the Java-class with JavaScript, it works. But it should also be possible to do that right after loading die Java Applet. Until 3 months ago it was working always properly on Mac with Firefox for 6 years. On Windows it still works perfect with Firefox. And it worked always perfect on Windows with Internet Exlorer and Chrome. I hope you can solve this problem. With Safari Java Applets don't run any more even Java is active in Safari. So my customers have just Firefox to work with on Mac. Chrome doesn't work on Mac. Here is my Code. The Applet is signed by symantec:
<html> <head> <applet code="testmacsigned.class" archive="testmacsigned.jar" width="0" height="0" mayscript name="testmac" id="testmac"></applet> <title>Offline Reservation hellocut</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <!--<object type="application/x-java-applet" name="testmac" id="testmac" width="10" height="10"> <param name="archive" value="testmacsigned.jar"> <param name="code" value="testmacsigned.class"> <param name="mayscript" value="yes"> <param name="scriptable" value="true"> </object>--> <!-- <embed code="testmacsigned.class" type="application/x-java-applet" archive="testmacsigned.jar" mayscript name="testmac"> <noembed> No Java Support. </noembed> </embed>--> <script language="JavaScript"> <!-- function fctapplet(){ window.document.testmac.testmacsigned(); } --> </script> </head> <body> <table> <tr> <td> <input type="button" onClick="javascript:fctapplet();" value="go"> </td> </tr> </table> <table> <tr> <td> </td> </tr> </table> <script language="JavaScript"> <!-- window.document.testmac.testmacsigned(); --> </script> </body> </html>
The last command - window.document.testmac.testmacsigned(); - doesn't work anymore because the Java Applet on the top isnt' loaded allready.
Moambuepyre
Opaite Mbohovái (17)
Hi firefoxproblemonmac, delayed availability of an object is a common problem addressed in JavaScript applications, so someone should be able to find a way... I've been forced to learn something about Java; since I only know what I've read, I can't offer any personal experience.
If you add a parameter to your applet code, you should be able to receive status updates:
<applet archive="testmacsigned.jar" code="testmacsigned.class" height="0" id="testmac" mayscript="" name="testmac" width="0"> <param name="java_status_events" value="true"> </applet>
In Oracle's example, they also have this, but I don't know what it does:
<param name="permissions" value="sandbox">
Then, to autostart the applet, you can try this:
<script type="text/javascript"> function myAppletSetup(){ var myApplet = document.getElementById("testmac"); switch (myApplet.status){ case 1: /* LOADING */ myApplet.onload = myAppletAutostart; break; case 2: /* READY */ myAppletAutostart(); break; case 3: /* ERROR */ alert("Error loading Java components!"); } } function myAppletAutostart(){ window.document.testmac.testmacsigned(); } window.onload = myAppletSetup; </script>
Regarding the load status, see: Oracle Docs - Applet Status And Event Handlers.
In the course of sketching this out I realized an error in my earlier suggestion -- this line should not have parentheses because I do not want appletgo to run immediately:
window.onload = appletgo;
Edit: Fixed typos...
Moambuepyre
Hi jscher2000...wow that's a very good hint. This sounds really interesting! I will test this tomorrow monday at the mac-computer of the customer.
In the meantime I was thinking already about other solutions. I try to manage everything without calling the Java-Applet with JavaScript. It's a lot of work to change everything (2 weeks probably). But it would work then again with Firefox on Mac and there would be also an other advantage. To call a Java-Applet-Class from JavaScript the java-security-level has to be high. When I get it without JavaScript it would work also with java-security-level very high. One Problem I have to solve. With the call of JavaScript I get a return-value. When I do everything just with Java-Applet I can put parameters but I don't get anything back. It's like a one way thing. But I try to give the return value from the java-applet direct to my asp-page. Here is the code from Java-applet:
URL url = new URL( getCodeBase().toString() + "confirm.asp"); getAppletContext().showDocument(url);
Moambuepyre
Hi firefoxproblemonmac, I noticed some typos when I came back to my post. Hopefully I fixed all of them: https://support.mozilla.org/questions/969639#answer-477451
There might be some parameter to start your applet without JavaScript; I don't know how to do that myself, but it's definitely worth a look.
Also, some propose changing <applet> to <object>/<embed> or <object> nested in another <object>. Not sure whether that changes the load behavior or the level of support you get in different browsers. The article I saw on that is: https://eyeasme.com/Shayne/XHTML/appletObject.html
Hi jscher2000...you answered all my question. no worry. I tested it 1 week ago with all the tags like <Applet> <object> and <embed>. The behavior was always exactly the same with Firefox on Mac.
I installed your hint already. With Firefox on Windows it works. On loading the html-page it goes into onload and when I press to "go" after the page is loaded, then it goes to ready. But on Windows it workes also without this load and ready-thing perfectly. So the JavaScript-Call make automatically this onload-thing. I'm excited to see tomorrow how it works on Mac with Firefox. If even this doesn't work it would be a huge bug of Firefox on Mac.
Moambuepyre
Hi Jscher2000...It tested it on mac (Firefox) with the ready and onload-thing. When I do it without loading it directly, the myApplet.status is 2=ready. Everything works as it always did. When I start the Java-Applet-class directly in html, the myApplet.status is undefined. It does nothing. There is not even the Status = 3 (error). It's just nothing. And the <param name="permissions" value="sandbox"> has no effect to this Problem.
It's definitly a huge bug of Firefox. There are problems worldwide because of this. With iMac you can't Login into the biggest bank of india for example. The reason is also this bug.
Moambuepyre
Hi firefoxproblemonmac, I don't know what you mean by this:
When I do it without loading it directly, the myApplet.status is 2=ready. Everything works as it always did. When I start the Java-Applet-class directly in html, the myApplet.status is undefined. It does nothing.
When you say "directly in HTML" do you mean in the myAppletAutostart() function or somewhere else?
I mean when I call the function myAppletAutostart() with window.onload then id doesn't work. I can not even start the Applet with a button afterwards. When I press the button "go" after loading the whole html (without window.onload) then it works. It's still exactly the same behavior. It doesn't work and there is for 100% no solution for this. Firefox has to fix this bug very quickly or they will loose millions of users all over the globe.
Moambuepyre
Hi firefoxproblemonmac, maybe it's a typo in your reply, but you do not want to call the function myAppletAutostart() with window.onload. That function should only be called by myAppletSetup() after it confirms that the applet is ready.
If you are saying that even checking the load status and having the script call the class after a successful load does not work on Mac Java, that is indeed very troubling.
sorry I mixed some things. You made it clear with the last sentence. Even checking the load Status isn't possible on mac Java with Firefox. Safari doesn't even load Java-applets. And Chrome doesn't work with Java on iMac. So finally it's absolutely not possible any more to work with mac and Java when you call it with JavaScript. If Apple would tell us that this is not possible anymore then it would be ok. But officialy it should work. It works with Windows and Linux and it was also working with Mac the last 7 years. I try to manage everything without JavaScript now. That's a huge work. It's like Apple would switch off the electricity for Java.
Moambuepyre
Hi firefoxproblemonmac, I have the same problem in using Java applet with Firefox on Mac. The problem seems related to JavaScript-Java communication. I have a HTML page with simple applet that return JVM version and vendor name. The applet also print out debug message to Java console after it is initialized. When the page is loaded, use applet.isActive() function to determine whether the applet is loaded. In Firefox on Mac, the applet.isActive() always return "not a function" no matter how long I wait after the page was loaded (eventhough the Java console shows the applet was initialized successfully). However, if I click the browser reload button, I may be able to get the javascript function applet.isActive() retrun true (around 5%-10% of chance). I tried to changing the applet/embed/object tags, use deployJava.js, add/remove codebase and permission in Manifest file, the results are the same.
Note: Safari on Mac, or Firefox on Windows has no problem at all.
Below is my configuration: OS X: 10.8.5 JRE: Java 7 Update 40 Firefox: 24.0
Hi Heung
I have exactly the same problem. This is a bug in Firefox. Unfortunately nobody from Mozilla recognized this so far. In my case it worked in 1% chance. It doesn't matter if you use Applet, object or embed-Tag. But just use the Applet-tag. It is the only tag who works everywhere. So I had to find a solution to make my program work without calling the applet with JavaScript.
I send the Parameter with <param Name="" value="">. Then I do all the work in the Applet with public void init(). When I need a value back to the html (or aspx in my case) I reload the same page directly in the applet. For example:
URL url = new URL( ....
getAppletContext().showDocument(url);
This way everything works without JavaScript. And it works everything with the security level very high in Java. To call an Applet with JavaScript just works with the security level high in Java.
It's strange that it works in Safari with Mac in your case. In my case applets absolutely doesn't work any more with Safari on iMac. I think it works with Mac OS 10.7 and lower. But with Mac OS 10.8. it absolutely doesn't work anymore. Officialy it should work so it's a huge bug of Mac OS 10.8. With Firefox it works but not with a JavaScript-Call directly at loading the html-page.
Tell me if there is something you didn't understand.
Moambuepyre
In order to make applet work in Safari with Mac, you can try reinstall the latest JRE from www.oracle.com.
Hi firefoxproblemonmac, the javascript-to-applet communication works find after I un-install the firefox from application folder, download a flash firefox copy, and then re-install it again.
Sorry, re-install firefox may not help. After few tries, the problem happens again.
It is strange that not every mac have this problem. My company has 2 MacBook Air and they dont have this applet problem.
Hi Heung
I reinstalled jre on imac with OS 10.8. There is no difference. I tested this on 2 different imac. Java-Applet absolutely doesn't work on imac with OS 10.8.
Is there OS 10.8 on MacBook Air? At least with imac OS 10.8 JavaScript-to-Applet communication doesn't work. I have this Problem on many different imac. It is a huge bug and nobody knows this at mozzilla. I tell all my customers to change to windows.
Hi firefoxproblemonmac, the problem seems resolved after update the JRE to Java 7 update 45.
Yes Yes.. I also tried this yesterday. When Java released 7.45 all applets (Safari, Chrome & FF) stopped working automatically. My Bank (BoB) started giving me same error message again. Then I downloaded latest version of JRE (7.45) and installed. Also cleared all old cache from Java Control Panel (from System Preferences). And it's working on FF. Surprisingly Safari is still not working but FF works.
I think Apple, Google, FB all are coming together against Oracle (after acquiring Sun & MySQL). Google shifting to MariaDB, FB will follow, Apple stopped supporting Java.. (also mozilla??) i think bad days of Java will start soon..