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".
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).
Add a redirect to the HTML page in question. Redirect to javaNotEnabledOrNotInstalled.html (but think of a less descriptive and silly name for it).
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!
Here is something js window.navigator.plugin
Related
Java Compatibility
I have been having some trouble with making a custom browser I am using a default class provided by oracle for a custom browser. One thing I noticed with the browser is that it cannot run java applets without some sort of variation of java browser plugins. How exactly do normal browsers receive information from a web server to run a java program externally? Is there any way to somehow point the browser toward the jre to run the app like on a normal browser. Just need somewhere to start. FireFox apparently references some sort of MIME format under the npjp2.dll native found in the jre directory. Thanks Very Much.
Oracle Example
You can provide the user with a standard html download page in order for him to download a JNLP file which is the standard file to start a java web start app (applet). If the user's system has java installed, it must recognize the .jnlp file and assosiate it as a java app. It's an extra step, for the user to manually download the file instead of running automatically on a web browser, however because of recent security loopholes on java web implementations, most browsers don't trust java anymore, therefore the blocking. If you insist on setting up a web start app in a browser you must make sure that all users have appropriate security configurations on ther java installation (very unlikely).
EDIT:
Here's a very nice tutorial on how to achieve what I just explained.
TUTORIAL
In general, browsers (I see this esp. with Safari) are kind enough to inhibit a Java applet from running if it senses that a security related update for Java exists. It seems to do this quietly... my applet just "sits-and-spins" in the browser window - never executes. Is there a way, preferably via JavaScript, to programmatically determine whether or not this condition will exist (so that, for example, applet loading can be skipped and some kind of informational message can be displayed)?
In my particular case, my applet quietly did nothing when launched with Java 1.6.0_37 (on Mac OSX 10.6, Safari 5.1.7). As soon as I updated to Java 1.6.0_43, the applet ran without incident.
The best approach is generally to poll for the existence of the applet using Javascript, and take alternate action after a specific time.
Note that the Deployment Toolkit Script is intended to ensure a valid Java version and run the applet while providing feed-back to the user, so it would be a better overall approach to deploying the applet.
I've recently been learning Processing, a sort of Java based visual language. It has a feature to export sketches/scripts as html documents and open them in a browser and run them with a java applet. However, when I try to open them (on a Mac OS X 10.5.8), it redirects me to the Java page telling me that Apple supplies its own version. I checked for software updates and tried downloading another version of Java to no avail. Also, I checked on a website to see if Firefox had Java, but it said it was disabled, despite my preferences having Javascript checked off.
Any help? Thanks.
You're running an unsupported version of Java, you need to update to 10.6 or higher to get the latest version. https://discussions.apple.com/thread/3995956?start=0&tstart=0
This belongs on https://apple.stackexchange.com/ as well.
Is that possible?
before entering a site, it should check whether java is installed and it has to be of a specific version before redirecting to the designated page.
javascript cannot be used because it can be turned off by the user.
java applet cannot be used to check as it can disabled by the user
thank you.
I think it is naive to assume that someone would have JS disabled but Java installed & enabled.
JS comes with the browser, but Java does not.
JS is enabled by default, and has to be explicitly disabled.
Many sites today either rely on JS, or give a much slicker user experience when JS is enabled.
The deployJava.js
is the latest strategy offered by Sun/Oracle for checking that a browser has a
specified minimum version of Java before running an applet or including a launch link for JWS
applications. If 90% of deployers of applets in the last 2-3 years use the script, what do you think the
chances are of seeing Java installed and enabled in those browsers where JS is disabled?
Sun's former way of ensuring an applet had a necessary version of the plug-in was using
HTMLConverter, which produced the nested OBJECT/EMBED element so hated by validation services
(and any self respecting web developer). This invalid HTML used no JS or Java to do what it did,
it all relied on HTML & the browser/user's ability and willingness to act on the said elements.
However I do not recommend using that approach, I think deployJava.js is a better way to achieve it.
If you are truly insistent on making every attempt to determine the user's Java, and do not mind
'breaking the back button', there are other techniques that can be used. E.G. have a series of pages.
The first page has a meta-refresh redirect to nojs.html set at NN seconds and uses JS to redirect to
hasjs.html immediately.
The hasjs.html tests for Java:
Detect if Java is enabled
Check Java version using something along the lines of javascript:alert(java.lang.System.getProperty('java.version')). It works in the address
bar of FF to pop a dialog that reports 1.6.0_24 on this box.
(Finally) to determine that the applet itself is active (as opposed to crashed/refused at run-time),
see Detect if an Applet is ready.
So as can be seen, JS will not only be able to check if Java is enabled, but can also check the version & that any specific applet has loaded successfully.
You can prompt the user to input which version of Java they have installed. Otherwise, no.
Well, without using Java Applet and without using JavaScript. What else can you use? You are trying to access client specific data, you can't grab such data in the server side.
Rewrite your application in .NET, and then you can enjoy User-Agent lines like this:
Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1;
.NET CLR 1.1.4322; .NET CLR 2.0.50727)2011-04-27 23:02:21
I wish browsers were sending same stuff for installed Java... alas, they don't.
I am deploying a signed & trusted applet. We need to run the applet in a separate JVM & increase the heap size. Setting separate_jvm & java_arguments works on our local boxes. Curiously we have clients that though they are using 1.6.0_15 don't seem to be running the new plugin architecture.
When I check their Java config, "use next-generation plugin" is checked & IE7's option "use Java 1.6.0_15 for applet plugin" is also checked. Nothing seems obviously wrong. The Java console also reports the correct version, but neither separate_jvm nor java_arguments are respected.
Just as a sanity check we wrapped the applet in a JNLP & set up our web page to serve the applet with a jnlp_href. The applet tag had a bogus code parameter to ensure the JVM was actually running the JNLP. The Java console complains that it cannot find the bogus class when it should be properly loading the JNLP.
Are there security settings or something else that might cause what I'm seeing?
I'm afraid I've just a few suggestions rather than an absolute answer.
The Java virtual machine version
and plug in version can be
different. Go to Control Panel,
Java, Runtime Environment settings.
When you check the console it may
show the two different versions.
The new plugin architecture would
depend on browser, Opera doesn't use
it at all, for example. IE7 does
though. So check which browser it
works on.
Java has got corrupted due to
repeated installs and uninstalls.
Pretty common complaint I've found.
If you have control over one of the
machines you should uninstall every
Java. Restart machine. Install
latest Java.