Can web developers stop IE popup dialog that Java is not installed? - java

I've developed a website (internal website behind a firewall) that uses a Java applet. If Java is not installed on the client, then it will fall back to other solutions.
The issue I now have is that at least IE9 pops-up a dialog saying that my webpage uses Java and how to install this. I'm already taking care of this on my webpage, so can I use some Meta tag or other to stop IE9 from ruining the user experience?
Users will think my webpage can't be run without Java when this pop-up is shown!
HTML
<applet
id="tinyApplet"
width="0"
height="0"
codebase="/applet"
archive="se.lu.ldc.tiny.jar"
code="se.lu.ldc.tiny.applet.Tiny">
Some HTML text
</applet>

Have JS check that Java is installed before ever writing the applet element. E.G.
When you type..
alert(java.lang.System.getProperty("java.version"));
In the FF JS console input line, you might see something like:
[02:55:46.025] alert(java.lang.System.getProperty("java.version"));
[02:55:46.027] ReferenceError: java is not defined
..if Java is not installed. If it is not installed, use the alternate content/strategy.
If the call to getProperty(String) returns a non null value, then Java is installed (and java.version is a property defined in that JRE).

Related

Java Applet Security Issues

I'm having a lot of difficulty getting an applet I made to run in a web browser. Java security keeps blocking it. I have the jar sitting on my desktop and I made a simple html file that embeds the jar using . I'm trying to embed this in html for my website. I don't have any root access to the site at all so I want to avoid using Web Start and Apache Tom Cat stuff because it seems those tutorials assume you're uploading the app itself to the directory of the site itself. I can only embed html here, so I have a jar located in my googledrive.com/host that I'm trying to link.
Here's the code for the tag.
<applet
codebase="https://bb2f18b1cb19b925c50b747c1c65afcc4ad11720.googledrive.com/host/0B34NA0csYJZufm5ZeFFEcUMyQnR5bmw1eVl2M3BOcXItNGxxZTZvaFExNVhXQnY4dzY3QTg"
archive="AsteroidGameApp.jar"
code="asteroidgame.AsteroidGame.class"
width=500
height=500>
</applet>
I don't even know if it would run correctly or not because I can't get past the security. I've read stuff about getting the code signed but I can't find a clear tutorial how to do that.
As reported on the Java related site Starting with Java 7 Update 51, trying to run unsigned Java applications generates error messages and prevents executing the applet.
Follow the instructions about the Oracle proper solution (I my experience I had to get a valid certificate from a trusted root like Verisign and then used this certificate to sign my applet jar) but if you can't do this way, try the suggested workaround in the correspondent section.
Obviously, as stated by the Java site:
It is highly recommended not to run these types of applications. However if you still want to run these apps, run only if you understand the risks and implications.

client side jar that controls parts of Firefox

I am a Java programmer. I would like to write a client-side Java program that adds-on to Firefox to perform operations on the HTML received from a specific remote web site, BEFORE that HTML is displayed in the user's browser. The client side Java program would have to:
Locate and read specific files on the local (end-user) machine on which it resides.
Check the URLs of web pages requested by Firefox.
If a URL requested through Firefox contains a specific domain:
Iterate through the HTML text looking for startcode and endcode.
Slice out the string between startcode and endcode.
Transform the string between startcode and endcode using info from file on local pc.
Replace the string between startcode and endcode with the transformed string.
Allow the Firefox browser window to display the modified HTML.
Basically, the Java program would intercept incoming HTML from a specific web site and alter the contents before the contents are displayed on the user's screen. How would I go about writing this kind of program?
Of course, I have administrative privileges on the computers that would run this program. But I have never written a browser add on before. I would like to write it in Java, but the code would need to always be on the client computer. The code could never be on the server. I do not know where to start this project.
#Athafoud is correct in general. No browser supports Java out of the box.
Instead:
You can write browser extensions for Firefox, Chrome, Safari, Opera in Javascript. E.g. the firefox-addon has a link list to get you started with Firefox extension development.
You can also write browser extensions for Firefox in C/C++ (to some extend) using either js-ctypes or XPCOM.
You can write some limited C++ stuff for Chrome via their NaCL APIs.
You could potentially write Java Applets for browsers that support the Java plugin and bundle them with and script them from your extension (to some extend) but that is a PITA.
Firefox extension APIs are the most capable as anything Firefox can do, extensions can do too (incl. calling into external libraries). Other browsers have far more limited extensibility/extension-facing APIs (due to architectural issues and sometimes in the name of security, although that bold security claim is... well, bold).
As for the particular requirements you gave in your question:
Firefox extensions are capable of transforming raw HTTP responses (although this is a bit cumbersome), as well as the DOM once HTML is parsed (from javascript). Firefox can read/write all files in the file system (abiding OS-level ACLs, of course).
Chrome extensions are not capable of transforming raw HTTP responses ATM, but you could modify the DOM once parsed. Also IIRC Chrome cannot read arbitrary files by default but you can manually enable read-access.
I dont think that you are able to use native java to write a firefox addon. You can use javascript. A good place to start is on Mozilla documentation site.
There is also a good guide here shortest-tutorial-for-firefox-extension, it is a bit old and the SDK has change, but i think is good start.
And a more update from mozzila itself how-to-develop-firefox-extension

ClassNotFoundException when accessing applet, but only for some

I recently got an email from a customer saying that they were getting errors on one of our web apps. We have a date/time picker applet that's used throughout this app and it's not displaying for this user. The tag in the HTML page is:
<APPLET CODE="com.enerwise.applet.datetime.DateTimeSelector" WIDTH=250 HEIGHT=30 codebase="/japps" name="app_date_start" align="middle" archive="DateTimeSelector.jar,VisualSoftJBCalendar.jar">
<PARAM NAME="locale" VALUE= "en_US" ><PARAM NAME="interval" VALUE= "-1" >
</APPLET>
The error he's reporting is ClassNotFoundException in com.enerwise.applet.datetime.DateTimeSelector. He's tried accessing the page from several different computers in his office and gets the same error. He has Java 1.7 installed (the applet is old; likely compiled with 1.4) and has tried from Win XP/IE8 and Win 7/IE9 machines. I've tried it from a Win XP/IE8 and a Win 7/IE9 machine with java 1.7 and had no problem.
He's the only customer (that I know of) having this problem. I'm stumped! I suggested that he try from a computer that's NOT on his work network; I haven't gotten a reply yet.
Can anyone suggest something to check on his system? I found another thread where the problem was the users proxy setting in the Java Console. I'll have him check that as well.
Is it possible that his company's IT dept. Made a change to their security and it's blocking applets/jar files? Would he get a ClassNotFound message in that case?
The JAR files of java applets are downloaded by the browser like any other files. You should be able to create a URL to those JARs, and ask the user to enter them in the browser and see if they are downloaded.
For example, if your applet is embedded in a page accessible by
http://yoursite.com/some/page.html
then the JAR URLs (in your case) should be something like:
http://yoursite.com/japps/DateTimeSelector.jar
http://yoursite.com/japps/VisualSoftJBCalendar.jar
(you have the /japps codebase specified in the applet tag).
Make your user enter them in the browser, and if they won't download, it's the company firewall, or they are physically missing from the web server.

How to detect Java and its version in AJAX app

I am working on web app with jquery, jqueryui, ajaxify and many jquery extensions.
At some point in the application I have to use Java applet.
The applet is run via ajax call, let's say jquery.load loads a page that generates applet code. I would like then to detect if Java is installed on the computer running the app, and if it is version 1.7+. The detection should occur only if applet is going to be used, since this functionality is to be used by limited number of users and only in certain circumstances.
I can't use deploy.js, as this script was not designed to be run via ajax call and simply fails.
I would like to detect java only when it it really needed, i.e. when user is going to launch the applet.
How can I do that?
I will appreciate your help.
You should use Java Deployment Toolkit in any case. When I need to some specific checks I open the java_deploy.js and see how this works. It not so hard to understand, really. For example, in Chrome it just inserts a specific tag with certaing uid. Nothing complicated. Then I just exec the code doing this manually.
At the end of deploy.js it just launch Java check after the page load. One method call. I've just removed this code and launch it manually in my own code.
Finally I found a way to detect if java is installed.
At first I tried with navigator.javaEnabled(), but it didn't work properly with IE.
Then I tried Java deployment toolkit, but didn't succeed due to window.write which was not compatible with pages fetched via ajax.
Then I tried to customize Java deployment toolkit following odiszapc advice ... but by the end of the day I used unmodified Java development toolkit, simply I used its versionCheck method.
If java is not detected, the user is told to download and install JRE, and link is provided.
If correct version of Java is installed then the subpage is reloaded via ajax with parameter javaOK=1. In such a case there is no java detection, just pure applet tags, in short:
$SuccessUrl = FileName . "?javaOK=1&" . $_SERVER['QUERY_STRING'];
(...)
$java_detect=EOQ (heredoc shoud be here, some tags don't work)
var version = '1.7'; //required version
var check = deployJava.versionCheck(version+"+"); //1.7 and higher
if(!check){
$("#sign_dialog").html("$java_err"); //wrong java or no java at all
}else{
$("#sign_dialog").load("$SuccessUrl");
}
EOQ;
(...)
if(isset($_GET['javaOK']) && $_GET['javaOK']=='1'){
echo $applet;
}else{
echo $java_detect;
}

Allow user to download a file generated by Java applet using Javascript API

I have a Java applet embedded into a web page which generates a file that the user must download. I understand there is a way to do this by communicating with a Javascript API.
Could somebody please explain to me how to do it this particular way?
Javascript doesn't allow file saving just yet, and the hacks that "work" need modern browser that understands data URI:s. In that case you would simply send the binary data as base64 and make the browser navigate to the data URI by setting document.location.href = 'data:application/octet-stream...' The download prompt would look like this in firefox:
http://img824.imageshack.us/img824/5080/octetstream.png
Flash allows for real download/save dialogs though so you could also look into that... or find out if java applets have that too.
If the user can be expected to have (or be willing to upgrade to) a Plug-In 2 architecture JRE (e.g. Sun's 1.6.0_10+)1, it is possible to launch the applet using Java Web Start. When an app. is launched using JWS, it can access the JNLP API, that offers file services that allow even sand-boxed code to save information to the local file-system.
Here is a demo of the JNLP files services.
That is if the applet needs to be embedded. JWS could launch applets free-floating since it was introduced in 1.2.

Categories

Resources