1

Is there a way to detect if java is installed on your machine or if java is disabled on the browser. We use java applets in our application but before the applet is loaded we use "deployJava.js". Sadly even if Java is disabled on the browser it says java is not installed.

So is there way to differentiate if Java is installed or Java is disabled, preferably using javascript. I have also tried using "navigator.javaEnabled()" but it gives me the same result as using "deployJava.js".

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
user1216750
  • 483
  • 3
  • 10
  • 17
  • I doubt it's possible. – Denys Séguret Jun 11 '13 at 14:57
  • Just check for disabled .... anyways you cannot enable it if it is disabled via javascript.. hope this previous post help http://stackoverflow.com/questions/14871287/how-to-check-whether-java-plugin-is-enabled-or-not-using-javascript/14871394#14871394 – AurA Jun 11 '13 at 15:47

3 Answers3

1

You can't.

And that would be very annoying if you could. There's already enough information leaking from the browser to the page, if it started telling people what I have installed but that I have ostensibly disabled, that would be very annoying.

I guess it could be possible and useful to envision an API for that, but in the current state there isn't any: either the plugin is here to be used, or it isn't. It doesn't matter whether it's installed or not.

I guess you'll have to work around it by stating in your user-facing messages that Java either needs to be installed or enabled. Or you could offer to download a diagnostic tool to run it and check it locally, that could be another working alternative, though with the obviously annoying extra-steps to perform (and an additional tool for you to support).

haylem
  • 22,460
  • 3
  • 67
  • 96
1
  1. Add a redirect to the HTML page in question. Redirect to javaNotEnabledOrNotInstalled.html (but think of a less descriptive and silly name for it).
  2. Early in the applet init(), call JS to cancel the redirect.

Note also that in the traditional applet element..

<applet 
  code=.. 
  width=.. 
  height=.. 
  alt='Java is installed but disabled!'>
No Java Plug-In installed in this browser.  Get Java free from..
</applet>

In this circumstance, if Java is not installed at all, the user should see..

No Java Plug-In installed in this browser. Get Java free from..

However if Java is installed but disabled, they should see..

Java is installed but disabled!

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
  • Interesting. Is that cross-browser? That seems highly-dependent on how they chose to handle the tag in this cirumstance and not codified by a document. – haylem Jun 11 '13 at 17:14
  • *"That seems highly-dependent on how they chose to handle the tag in this cirumstance"* It is an element rather than a tag, and its use is well defined by the W3C. OTOH I think the 1st approach *would* be more reliable. – Andrew Thompson Jun 11 '13 at 19:40
  • not sure I get your distinction between element and tag in this context. I know applet is spec-ed, but I had never read (and I don't see it in the spec now) the behavior would be to display the element's text content if no corresponding plugin is found, or to display the alt text in the placeholder if it fails to load, and that a disabled plugin would cause the latter.Considering your expertise with embedded Java components, I'll happily trust you on it working though. Just not sure it's as reliable solution.Then again, in browsers, following the spec isn't guarantee of reliability... – haylem Jun 11 '13 at 22:34
  • *"not sure I get your distinction between element and tag in this context."* One is right, the other ..isn't. *"Then again, in browsers, following the spec isn't guarantee of reliability..."* Agreed. – Andrew Thompson Jun 12 '13 at 05:10
  • sorry to bother you, but as far as I know in a text context tag and element describe the same thing. If you're talking about the objects, then obviously only element is valid. And we were talking about sources here. Or if it's something else, thanks for clarifying my blind spot. – haylem Jun 12 '13 at 10:33
  • *"in a text context"* What does that mean in *your* head? Here it reads like nonsense. The term is either correct or not, in the case of `tag`, it is not correct. There is no such thing as an HTML 'tag', though there is a common *misconception* that there is. – Andrew Thompson Jun 12 '13 at 10:38
  • Nevermind. I'll leave you to fight off terms that have been misused since as far off as I remember HTML having been around, then. – haylem Jun 12 '13 at 10:48
0

Here is something js window.navigator.plugin

Sunny Patel
  • 535
  • 2
  • 5
  • 13
  • @sissonb: you are right, it's navigator.plugins, with an "s", which works in FF and chrome, and should include java when enabled. – dandavis Jun 11 '13 at 15:22