Solved

Auto Detect and Install Java VM

Posted on 2004-03-26
5
696 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

687 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