porst17
porst17

Reputation: 377

Local Java applets not shown in Firefox

I have problems running Java applets locally, i.e. the class files reside in the local file system, not on a server. The following example

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
    <body>
        <applet code="Java10Test.class"
            width=200
            height=200
            codebase="http://www.cis.upenn.edu/~matuszek/General/JavaVersionTests/"
            >
        </applet>
        Text ...
    </body>
</html>

works well with Firefox 23 and Oracle Java 7u25. But it does not work if I download Java10Test.class to my local machine and put it in the same folder as the .html no matter what codebase I use. I tried codebase="." and codebase="file:///pathToTheFolder" without success. Firefox does not even reserve the 200x200 space for the applet. Java is also not started in the background (the Java console does not open as it does for all other applets), i.e. it is not a Java security issue. There are no warning/error messages.

The local version works in Chrome without problems. The behaviour is reproducable on different machines (Mac/Linux).

What is the correct way to use applets locally in Firefox? I need this for a system without access to the internet.

Upvotes: 2

Views: 3231

Answers (2)

porst17
porst17

Reputation: 377

This is a known bug in Firefox 23. It should block the use of locally insecure codebases like .. but accidentally blocks other local paths, too.

The currently known workarounds are:

  • set security.fileuri.strict_origin_policy=false in about:config
  • use a local web server instead of local files as suggested in the other answer

Upvotes: 2

Andrew Thompson
Andrew Thompson

Reputation: 168815

What is the correct way to use applets locally in Firefox?

Run them from a server at localhost (e.g. install Apache) and they should show the same behavior as on the net.

..it would still be interesting, why the local class file is not used properly.

I'd suggest it is related to security. IE has long prompted an HTML running a script when it is loaded from the local file system. In general, 'a network' is considered a safer environment than your own disks.

Incidentally, I run FF and noted it recently started failing when running the Deployment Toolkit Script used for embedding applets and launching JWS apps. I had not realized it simply (and completely) ignored 'local (unjar'd, unsigned) applet elements' until I tested with yours. The fact it ignores them without warning or prompt is ..disturbing, at least for developers who have to write or maintain applets. :(


The only way to be confident an applet is loaded successfully, is to use JS to query the applet after it is loaded. If a public method of the applet cannot be accessed from JS after a specific time, presume the applet failed to load for whatever reason and proceed from there.

Upvotes: 2

Related Questions