Solved

Auto Detect and Install Java VM

Posted on 2004-03-26
5
688 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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

Showing your events from Google Calendar in Google Maps Why? I travel all week and I thought it would be ideal if staff in office knew where I was based on my calendar. (OK real reason: my son wanted to see where I would be working, and I thoug…
Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

762 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

24 Experts available now in Live!

Get 1:1 Help Now