Link to home
Start Free TrialLog in
Avatar of jpick
jpickFlag for United States of America

asked on

Detecting Java support on XP (and in IE )

Our product uses Java and we are trying to detect if a java plugin has been installed on a client's machine.  When using XP, Clients are propted to download java when a web page tries to load an applet.  I'm wondering if there is a way to detect if the browser can run an applet before this dialog presents itself?

The solution must be some client-side script that can detect both Sun's JVM and MSJVM.  I am aware of the XML interface to IE that allows you to check for MSJVM (although I have not tested it yet).  What I'm really looking to do is find out what the user has so our application can download the appropriate tools for them.

Any help is appreciated.

-Jeff
Avatar of web4net
web4net
Flag of United States of America image

Did you try the following?

The following code seems to work on a mac (ie5) as well as pc (ie, netscape6+, opera 5+):-

<script language="javascript" type="text/javascript">
<!--
var i_java;
var v_java;
// -->
</script>
<script language="vbscript">
<!--
on error resume next
i_java = IsObject(CreateObject("Java"))
// -->
</script>
<script language="javascript" type="text/javascript">
<!--
if (navigator.mimeTypes && navigator.mimeTypes.length)
 if (typeof(navigator.mimeTypes['application/x-java-vm']) != "undefined")
   i_java = true;
if (navigator.plugins) {
 for (var i=0; i < navigator.plugins.length; i++) {
   if (navigator.plugins[i].name.indexOf("Java Plug-in") >= 0) {
     i_java = true;
     v_java = navigator.plugins[i].description.substring(navigator.plugins[i].description.lastIndexOf("Plug-in ") + 8, navigator.plugins[i].description.lastIndexOf(" for"));
     break;
   }
 }
}
// -->
</script>

Java enabled -
<script language="javascript" type="text/javascript"><!--
(navigator.javaEnabled()) ? document.writeln("Java is enabled!") : document.writeln("Java is NOT enabled!");
// --></script>

Java supported -
<script language="javascript" type="text/javascript"><!--
if (i_java || navigator.javaEnabled()) {
 document.writeln("Yes");
 if (v_java) {
   document.writeln(" - version " + v_java);
 }
} else {
 document.writeln("No or unable to detect...");
}
// --></script>
Avatar of jpick

ASKER

Thanks for the code, I'm dealing with another crisis today, hopefully I'll be able to check out the code this evening.
anything?
any luck? did it solve your problem???
Still waiting for an answer
Avatar of jpick

ASKER

Well,  sorry it took me so long to get back to you.  The short answer is I don't know since I lost my job last week.  Since I don't have access to the XP box anymore I won't be able to give you an answer.
ASKER CERTIFIED SOLUTION
Avatar of web4net
web4net
Flag of United States of America image

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
thank you ... :))

And again, good luck.