Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
jQuery plugin to verify whether a browser has java installed
JavaScript Java
Branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
class
java
sample
README
jquery.hasjava.js

README

With Apple's recent decision to stop shipping java by default, and the current state of the union on Windows,
where java is not installed by default either, you cannot rely on having java inside a browser.  This plugin 
gives you a simple interface to check for the existence of java so that you can choose before loading a larger applet.

Why not just use the alternateHtml inside the <applet> tags?  Many webapps these days dynamically build HTML, and putting
text inside the <applet> tags does not give you any control over the presentation of the message.  I am building a webapp
where the applet itself is tiny and the UI is completely outside the applet in the HTML of the webpage.  Given all that, 
I wanted a way to programmatically determine whether an applet can be loaded.

Live demo: http://vivoh.com/jqueryhasjava/sample/sample.html

Sample usage 

<html>
<body>
<script type="text/javascript"
        src="http://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load("jquery", "1.4.4");

function testingForJava( success ) {
  $('.doWeHaveJava').html( success ? 'We have java, hurray!' : 'Unfortunately java is not supported' );
}

google.setOnLoadCallback(function() {
  // Second parameter is optional for classpath of java .class files,
  // but please store the applet on your site if possible (otherwise it uses github's copy)
  $.hasJava( testingForJava, '/jqueryhasjava' );
});
</script>
<div class="doWeHaveJava">
Please wait, determining if we have java available
</div>
</body>
</html>
Something went wrong with that request. Please try again.