Solved

Auto Detect and Install Java VM

Posted on 2004-03-26
5
690 Views
Last Modified: 2012-08-14
I need to auto detect for the latest version of java (or java vm or jre) so that users can run an applet.  If java is not enabled, installed or running it should open the java.com page in a new window that will then install the latest version of java.

I just need the exact code required to do this.  I have read about using the object tag and some other ideas but the exact code for html is what I need.  Also, this code should work on all browsers and OS.  I am sure this has been done before but I having trouble finding the exact answer.  

Thanks!
0
Comment
Question by:brianrandy
  • 3
5 Comments
 
LVL 36

Accepted Solution

by:
Zyloch earned 125 total points
ID: 10845988
I am not sure if you can detect the LATEST version of Java. However, it is possible to check to see if Java is enabled with a little bit of JavaScript.

In the body or head of your document, you can include this script:

<html>
<head>
<title>Title</title>
<script language="JavaScript">
<!--Hide from older browsers
function check_java() {
  if (navigator.javaEnabled()) {
    return true;
  }
  else {
    var width=screen.width;
    var height=screen.height;
    newWin = window.open('http://java.sun.com/j2se/1.4.2/download.html','newWind', 'toolbar=yes,location=yes,scrollbars=yes,directories=yes,status=yes,menubar=yes,copyhistory=yes,width='+width+',height='+height);
   newWin.focus();
   return true;  }
}
// -->
</script>
</head>
<body onload="check_java();">
Content
</body>
</html>

This is a short example of the best you can do with HTML and JavaScript alone.

This script using the onLoad event handler, as soon as the site loads, does the check_java() function.
check_java performs a check to see if Java is enabled. If it is, it returns true and does nothing. If Java isn't enabled, it will open to the download page. Please provide instructions to download the Java JRE as it is not possible to directly link to the download page because of session IDs (you can alert them in an alert box possibly or another popup)

The other way to do this is to upload the newest Java JRE to another site of your own so you can directly link to the file and start download immediately. However, the downside to that method is that it may be illegal. Also, some people may just have Java disabled and don't need to download the installation file.

Hope this helps :)

0
 
LVL 36

Expert Comment

by:Zyloch
ID: 10846018
Also, one more thing. I noticed that above, I typed:

var width=screen.width;
var height=screen.height;

You may wish to change it to:

var width=screen.width;
var height=screen.height-40;

Otherwise, the browser may obscure the Start Menu.

Another change you MAY want to change is where I typed:

newWin = window.open('http://java.sun.com/j2se/1.4.2/download.html','newWind', 'toolbar=yes,location=yes,scrollbars=yes,directories=yes,status=yes,menubar=yes,copyhistory=yes,width='+width+',height='+height);

You may wish to add this to right after copyhistory=yes:

...ubar=yes,copyhistory=yes,resizable=yes,width='...

The resizable allows the browser to be resized.

I hope this supplementary post helps.

0
 
LVL 36

Expert Comment

by:Zyloch
ID: 10846055
Finally, I would like to point out a problem with the above method:

If your users have a popup blocker, you may have to also warn them on the page to disable it.

Mozilla Firefox v0.8, I know for a fact, suppresses popups automatically. To stop that, tell your Mozilla Firefox visitors to go to

Tools -> Options
Click on Web Features in Menu at left.
Uncheck the Block Popups checkbox.
Click Ok.

The above script has been tested in Netscape, Internet Explorer, Mozilla Firefox, and Opera. All seem to work fine.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses four methods for overlaying images in a container on a web page
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
In this Micro Tutorial viewers will learn how to create navigation buttons that change on rollover, using CSS (Continuation of the CSS Image Sprite tutorial) Create a parent ID for all the list items       - Specify position: absolute and display: block…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now