jar file not named .jar and "Applet .. notinited"

  • Thread starter Antti Järvinen
  • Start date
A

Antti Järvinen

Dear Sirs,

there seems to be some kind of magic regarding naming of jar files
when loading an applet via web browser. Lets say I have foo.jar
and reference it via html this way
<applet code="Foo.class" archive="foo.jar" width="200" height="50"></applet>
everything works jolly well.

If I rename "foo.jar" to plain "foo" and change my html to say
<applet code="Foo.class" archive="foo" width="200" height="50"></applet>
then my web browser tells me "Applet Foo notinited". This happens with java
1.4.2 having mozilla or netscape around. Oddly enough, in mozilla, if I
re-load the page, then the applet does get started. In netscape this does not
help. I have here made sure that mime-type of file "foo" is right.

Is there any other work-around than naming the jar files with .jar
extension?

I'm having a system where the URLs pointing to various stuff, including .jar
files, do not have anything to do with original filenames ; I might be
able to change that but is there any other way to make java to recognize
jar files as jar files regardless of URL ending?
 
A

Antti Järvinen

If I rename "foo.jar" to plain "foo" and change my html to say
<applet code="Foo.class" archive="foo" width="200" height="50"></applet>
then my web browser tells me "Applet Foo notinited". This happens with java

But that gets fixed by adding a parameter
<param name="archive" value="foo"></param>
but then, having java 1.6 the "foo" does not get run while being
served via https:// url, via http:// url it works. SSL-enabled httpd
has expired certificate, this is most likely the reason? Has this
thing changed from 1.4.2 java (where everything now works) to 1.6.0
where this now works but not when behind a secure connection?
 
A

Andrew Thompson

Dear Sirs,

there seems to be some kind of magic regarding naming of jar files
when loading anappletvia web browser.

No 'magic', though Sun has not been particularly clear
that they expect archives to end in '.jar'. A recent
bug showed that the plug-in (for applets and web start)
would not check security certificates for '.zip' files,
which a lot of projects had come to use over the years.

The plug-in could access the resources within the .zip
just fine, its just it would not consider the code to
be trusted.

Use .jar extension and and forget about it, or pursue what
'flavor of the minute' adjustments might make another file
type work, and spend the rest of the app. time on maintenance.
 
A

Antti Järvinen

Roedy Green said:
That does not make any sense. Why would you expect misnamed jars to
work? Why do you want them to?

Well, concept of "file name" while being used in URL is a bit difficult,
in this system I have in hand it is for instance possible to specify
the version of the file, lets say I type in an URL of form
"http://foobar.com/file.jar?version=xyz"
where the "file.jar" may be understandable by human reader but
most URI parsers may be a bit confuzed. Now it actually replaces the
"name" with a number, making the url to be of form
"http://foobar.com/fileid=123?version=456"
Consider also that your webserver sends out the correct mime type for
jars, but not for jars renamed without the .jar extension.

Well, the mime type is correct. The jar is being served via CGI program
that has odd-looking URL but it knows the mime type of each binary no
problem.
For the scoop on the <APPLET tag, see
http://mindprod.com/jgloss/applet.html

yep, thanks.
 
M

Mark Thornton

Roedy said:
That does not make any sense. Why would you expect misnamed jars to
work? Why do you want them to?

They ought to work because the web server supplies the correct MIME
type. The MIME type rather than the extension ought to be the
authoritative type of the file. As for why, some web servers can't
easily be configured to serve .jar files. For example the web server in
my NAS device can use PHP to deliver a jar file but the url has to have
a .PHP extension so that a script is executed to deliver the file. The
only other way to alter the configuration of the server to deliver .jar
files requires voiding the warranty.

Mark Thornton
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,982
Messages
2,570,189
Members
46,735
Latest member
HikmatRamazanov

Latest Threads

Top