aspose file tools*
The moose likes Applets and the fly likes Force to use Sun JVM if available Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Applets
Bookmark "Force to use Sun JVM if available" Watch "Force to use Sun JVM if available" New topic
Author

Force to use Sun JVM if available

Fredrik Ronnlund
Greenhorn

Joined: Jan 09, 2007
Posts: 5
How do I make my applet (running on IExplorer) use Sun's JVM as default and Microsoft's only if no Sun version is available?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41572
    
  54
Hello fredu-

Welcome to JavaRanch.

On your way in you may have missed that we have a policy on screen names here at JavaRanch. Basically, it must consist of a first name, a space, and a last name, and not be obviously fictitious. Since yours does not conform with it, please take a moment to change it, which you can do right here.

As to your question, you can use the OBJECT tag instead of the APPLET tag. All the details are in the Plugin Developers Guide.


Ping & DNS - my free Android networking tools app
Fredrik Ronnlund
Greenhorn

Joined: Jan 09, 2007
Posts: 5
Sorry, didn't realize that I had to have my full name (fixed).

Anyway, as I understand it the classid tag takes care of directing which JRE to use (Sun's or MS's). But, could somebody give me an example of how I make the machine use Sun's (whatever version) if available and otherwise MS. AND the other way around: force it to use MS only.

My clients only have IExplorer.

Many thanks!
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41572
    
  54
The section labelled "Java Plug-in Anywhere" in the Plugin Dev Guide talks about how to structure the HTML so that it uses the plugin if available, and the native Java implementation if necessary.
Fredrik Ronnlund
Greenhorn

Joined: Jan 09, 2007
Posts: 5
The problem is that the "Java Plug-in Anywhere" discusses the situation where the browser and environment determine what JVM to use via Javascript... but in my case the browser and the environment are the same in all cases (WinXP and IE).

But the machines are as follows:
1)some MSJVM only
2)some SUNJVM only
3)some have both and MSJVM as default
4)some have both and SUNVJM as default

and I would like to in the above cases:
1) use MSJVM
2) use SUNJVM
3) use SUNJVM
4) use SUNJVM

Please advice...
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41572
    
  54
The Sun plugin should be detectable by a bit of JavaScript code, like this one:



So if the Sun Plugin is present, write an OBJECT tag, and otherwise an APPLET tag.
Fredrik Ronnlund
Greenhorn

Joined: Jan 09, 2007
Posts: 5
Thanks for the quick reply, but sadly it doesn't work as IE doesn't support the navigator.plugins -tag... always returns an empty array...
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41572
    
  54
Oh, right, that's a Win IE thing I forgot about. You need to use VBScript instead of JavaScript. All the gory details (and ready-made code to detect plugins) can be found here. Adding detection of the Java plugin should be a piece of cake.
[ January 10, 2007: Message edited by: Ulf Dittmer ]
Fredrik Ronnlund
Greenhorn

Joined: Jan 09, 2007
Posts: 5
Thanks, it works and checks if sun's jvm is installed...but, the problem still persists.

I need to force IExplorer to use SUN's JVM even when it is not set as active in IExplorer... any way to do this?

Using the OBJECT-tag and telling it to use a specific clsid makes IE give a warning and instructs the user to change the currently active JVM. I would need a way to force my applet to use Sun's JVM without the users having to do anything about it.
[ January 10, 2007: Message edited by: Fredrik Ronnlund ]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Force to use Sun JVM if available