3

When I run the following command on my Mavericks Mac:

appletviewer index.html

The appletviewer process starts, but no window shows up with the actual applet, I need use kill -s 9 on the process to get the process to terminate.

I have installed and reinstalled java via Oracle's instructions (deleting the plugin and then reinstalling). Java applet permissions are set to medium.

Here is the output of java -version

java version "1.7.0_51"
Java(TM) SE Runtime Environment (build 1.7.0_51-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.51-b03, mixed mode)

The java code and html file works fine on the remote linux machine:

<html>
<body>
  <applet
    code = "MyApplet.class"
    width = 500
    height = 400>
  </applet>
</body>
</html>

Here's some sample java code that I could reproduce this error with

import java.applet.Applet;
import java.awt.Graphics;

public class MyApplet extends Applet {
    public void paint(Graphics g) {
        g.drawString("Hello world!", 50, 25);
    }
}

Looks like it is related to this question, but those answers are also unsatisfying and don't help...

Community
  • 1
  • 1
ardent
  • 2,453
  • 1
  • 16
  • 15
  • For better help sooner, post a [MCTaRE](http://stackoverflow.com/help/mcve) (Minimal Complete Tested and Readable Example). – Andrew Thompson Mar 08 '14 at 03:41
  • @AndrewThompson , any tips on making this more minimal and readable? The problem is appletviewer process starts, nothing shows up. I'm on Mac OSX, this is not a problem that happens on Linux. I've uninstalled and reinstalled java and adjusted the security permissions. I've provided my version of java in case that was the problem. Also posted the HTML file that I use. It works online, it does not work with appletviewer. – ardent Mar 08 '14 at 06:02
  • *"any tips on making this more minimal and readable?"* 'This' ..what? I was referring to Java code, and there is none in the question. – Andrew Thompson Mar 08 '14 at 06:08
  • There is no problem with the java code, it compiles and runs fine on CentOS. It seems that Java 7's new security settings for Mac fundamentally break appletviewer and you would need to use Java 6 to get it to work aagin. – ardent Mar 09 '14 at 11:35
  • *"There is no problem with the java code, it compiles and runs fine on CentOS."* 'Running fine' on one JRE is no proof the code is not the problem. There were applets that ran just fine on Sun's JRE but broke on that of MS, not because MS' VM was broken, but simply because it got through a series of operations faster than Sun's and *revealed* a concurrency problem within the code. Your conclusions, and answer, are therefore highly suspect. But hey, believe whatever you want. – Andrew Thompson Mar 09 '14 at 11:43
  • @AndrewThompson, you're right. I apologize. I've provided the sample applet that I used in testing. – ardent Mar 10 '14 at 08:55
  • OK thanks. You've convinced me. There is nothing in that applet that should mandate it is done on the EDT (the `paint(Graphics)` method should always be called on the EDT, but we need to trust the JVM to do that, it is out of our hands). Beyond that ..there's p*ss all else that could go wrong in the code, it **must** be the JVM that is the problem. – Andrew Thompson Mar 10 '14 at 10:16
  • Hang on.. the applet paints a `String` at x co-ord 50 pixels, but the HTML only specifies 50 pixels wide for the entire applet! I.E. the `String` would not appear in the space requested for the applet.. – Andrew Thompson Mar 10 '14 at 10:18
  • @AndrewThompson The problem is that the applet window itself just doesn't appear, the original applet html spec is 500 by 400, and even then it doesn't show up. The problem started when testing a different applet locally, so I reduced it down to a hello, world applet. But kept the same width and height which I've edited back into the question itself. – ardent Mar 10 '14 at 19:36
  • OK. That is indeed sad news in this day and age. Still, that has always been the problem with applets. I checked some years ago and found the number of bugs specifically in regard to applets averaged out to one every two weeks since Java 1.1. In some version of some JRE in some browser, applets would not work fully, or sometimes at all. If this applet were not inherently in need of embedding **in** a web page, I'd say to launch it free-floating using [Java Web Start](http://stackoverflow.com/tags/java-web-start/info). – Andrew Thompson Mar 11 '14 at 10:36

1 Answers1

1

Unfortunately it seems from testing and forum trawling that the only real solution is to use Java 6.

Java 7's on Mac OSX seem to fundamentally break something that prevents the original Java 6 appletviewer from running properly.

An Apple Support page seems to imply that the bundled appletviewer is dependent on the JRE 6.

ardent
  • 2,453
  • 1
  • 16
  • 15