Link to home
Start Free TrialLog in
Avatar of aj_2003
aj_2003

asked on

simple applet and java exe questions

Hi, I have 2 questions.

1)
I made an applet. The applet tag in the html file looks like the following:

"<APPLET CODE="Applet.class" width="800" height="500">
</APPLET>"

How do I change the above tag so that when someone tries to run the applet on a machine that doesn't have Java, the browser goes and downloads the java plug-in automatically?

2)
I used some program to convert a class/jar file into an exe. It runs fine on a computer with a Java Runtime environment. But when I  tried to run it on a computer that does not have Java, it doesn't run. Isn't the whole point of an executable to be able to run independantly? Is there a way I can accomplish this?

Thanks
AJ
Avatar of SuperKarateMonkey
SuperKarateMonkey

First of all, MS bundles their Java plug-in with IE, so that covers an awful lot of your codebase.  However, if you really want to force the user to dynamically download the proper Sun Java plug-in, you can do so with the <OBJECT>,(for IE,) and <EMBED>, (for Netscape,) tags, instead of the <APPLET> tag, though only <APPLET> is universally supported:

For IE:

<OBJECT classid=="clsid:CAFEEFAC-0014-0002-0000-ABCDEFFEDCBA"
              width="800" height="500"
              codebase="http://java.sun.com/products/plugin/autodl/jinstall-1_4_2-windows-i586.cab#Version=1,4,2,0">

    <PARAM name="code" value="Applet.class" />
    <PARAM name="type" value="application/x-java-applet;jpi-version=1.4.2">
</OBJECT>

This will instruct IE to go get the SUN Java Plug-In if the version specified, (in this case, 1.4.2,) is greater than the available version, of if no version is available at all.  Note that some of the attributes from the <APPLET> tag are retained AS ATTRIBUTES in the <OBJECT> tag, such as height and width, whilst others are converted into <PARAM name="attributeName" value="attributeValue" /> format.  ALSO IMPORTANT:  The value of the codebase ATTRIBUTE of the <OBJECT> tag has NOTHING to do with the applet codebase.  It's the location that IE can download the .cab file for the Java Plug-In from.  If you want to specify an <APPLET> codebase, use the <PARAM name="codebase" ... /> format.

A similar procedure is used with the <EMBED> tag for Netscape.  You'll have to include both if you need to support both.  God only knows what the other browsers, such as Opera, Lynx, and Konqueror support.  You'll have to check their documentation, as well as the W3C, who defined the <OBJECT> and <EMBED> tags.  As for Mozilla, the most popular Non IE/Netscape browser, I suspect it basically behaves like Netscape, since they share much of the same code tree.
ASKER CERTIFIED SOLUTION
Avatar of SuperKarateMonkey
SuperKarateMonkey

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Oh, by the way, in response to your first question, there's an excellent resource on the applet tagging conventions here:

http://java.sun.com/j2se/1.4.2/docs/guide/plugin/developer_guide/using_tags.html
Avatar of aj_2003

ASKER

You were right...the program i downloaded simply wrapped a jar into an exe and thus needed a Java runtime environment.

Thanks for your sources about native compilers. I have never used visual age before but we have a license for it, so I'll look into how to use it to do this.

Thanks for your help.
AJ