Custom Search

CrossBrowser Java Plugin detection using JavaScript

In this article we will understand how to detect whether the client browser has Java Plugin Installed. This process involves communication between Java and JavaScript.





NOTE:
This tutorial cannot detect the Java Plugin Version installed.
The following steps will guide you to process of detecting Java Plugin on client machine using JavaScript:

1
2
3
4
5
6
7
8
9
import java.applet.Applet;
import java.awt.*;
public class checkJava extends Applet 
{
    public boolean setMessage() 
	{
		return true;
    }
}

Explanation for Java Code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<html>
    <body>
        <applet code="checkJava"
            width="1"
            height="1"
            mayscript="mayscript"
            name="checkJava">
        </applet>
 
        <script language="javascript">
		try
		{
			var x = checkJava.setMessage();	
			alert(x);
		}
		catch(e)
		{
			alert("Java Plugin Not Installed");
		}	
        </script>
    </body>
</html>

Explanation for JavaScript Code:

Custom Search

Related Post

Did you enjoy this post? Why not leave a comment below and continue the conversation, or subscribe to my feed and get articles like this delivered automatically to your feed reader.

Comments

It may take a while, until the applet loads, but the script is executed immediately. So I don’t believe this is a reliable solution. Sorry.

Hi kopsik,
Nice to hear this feedback from you. But i searched the internet for an good solution on this but unfortunately JavaScript alone cannot detect Java Plugin if you are targeting Multiple Browsers i.e. IE, Mozilla Firefox, Opera etc. Also i checked this solution on Firefox, IE, Opera and it works fine.

Yes, it is possible, but there might be an delay.

See http://www.browserreport.com/ for crossbrowser Java detection.

Hi Hitesh,

checkJava.setMessage();
is not working in Mozilla 3 version
it says that checkJava.setMessage() is not a function

I have used like this

Hi Sachin,
The javascript engine parser differs for browsers. Will have to check how we can detect the same on Firefox 3.0.

Hitesh Agarwal

Your blog is interesting!

Keep up the good work!

Leave a comment

(required)

(required)