Alternatives to Java Applet running with NPAPI in Chrome - java

We have an Applet we used to zip files on the client machine and stream the content back to our servers. Our clients that have updated to the newer versions of Chrome are no longer able to use our Applet because Chrome does not support NPAPI plugins any longer.
I think I have a couple of options:
To somehow make the existing Applet work with Chrome (perhaps using JNLP? ) or some other method
To find an alternative technology altogether
The solution has to be able to receive a list of folders, sub-folders and file names. It then has to be able to compress these files, if possible, then upload them to the server. I am open to any suggestions.

You can
Read the file(s) with the File API, potentially letting the user add them to your interface via drag and drop (for a more convenient selection mechanism than boring <input type="file"> :-) ).
Zip them up in JavaScript using a library like JSZip (though if your server has gzip enabled, I'm not sure you gain a lot doing that; I haven't looked into it deeply, though)
Send them to the server either via HTTP POST (possibly multiple posts), or by using XMLHttpRequest2, or via web sockets.
Of course, your other alternative is to continue to use Java and have the users use Firefox instead of Chrome. Just beware that Mozilla is also looking to make a move away from NPAPI and away from supporting Java. About 20 months ago they weren't:
there are no plans of dropping support for java or other npapi plugins in firefox other than setting them to "ask to activate": https://blog.mozilla.org/security/2014/02/28/update-on-plugin-activation/
....but now:
Mozilla intends to remove support for most NPAPI plugins in Firefox by the end of 2016. Firefox began this process several years ago...
(which puts the lie to "no plans" in the first quote)
...Websites and publishers which currently use plugins such as Silverlight or Java should accelerate their transition to Web technologies.

Related

Replace Applet in downloading and executing a file

I have an application that has an applet that does two simple things:
Download an executable jar file from our server (if the user doesn't already have it) to an specific folder in the user's PC
Execute the jar file with the corresponding parameters
This jar file monitors an Office file for changes and send it back to our server.
The problem is the war Chrome is creating with Java with this NPAPI thing. So I have until September to think of an alternate technology or stop the Chrome support.
Do you think of some other way to achieve the same result? Just download and execute. Doesn't seem that hard =(. Can HTML 5 do that?
EDIT
I was looking into Java Web Start and became a little happy. It appears that it can do what I want: executing a up to date jar file passing parameters. But I never worked with JWS, so I have some doubts:
Is it possible to pass parameters to it? I read about some JSP files that you can configure to do that, but I'm still unsure.
Theoretically, it should start automatically from a browser link, am I right? I tried this site:
https://docs.oracle.com/javase/tutorial/deployment/webstart/running.html
and it didn't work that way. I had to mark "always open files of that type" on Google Chrome. Is there a way for automatize it?
Thanks again!!
From what I know there are at least two things that allow you to stick with Java.
Webstart
Install4
Webstart is provided by Oracle and allows you to download Java program from the web and execute them. Update mechanisms exist, so you can always provide a current version.
Install4J (or any other installer for Java applications that offers an update mechanism) provides an installer which enables your customer to install an application which afterwards will be kept up to date by the integrated update mechanism. But Install4J comes at a price, there might be freeware / open source alternatives. Install4J and its alternatives are often discussed here on SO, you might want to check here.
I think the FileAPI of HTML5 is limited and can not access arbitrary files because a sandbox prevents this. You might check SO again for details about that.

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

Replacement for Jaxer for parsing/crawling websites

I have an old tool an (ex-)colleague wrote a few years back with Jaxer, that I'd like to replace/rewrite.
Jaxer is an (abandoned) server-side framework based on a headless Mozilla/Gecko-Browser allowing you to use JavaScript and the DOM server-side.
Since Jaxer is abandoned and because I have big problems installing and running Aptana Studio 1.5 with Jaxer on a new computer, I'm looking for a library/framework/something on which I can base a new version.
This tool is only run locally inside Aptana Studio (the IDE for Jaxer) and was never intended to be an actual web app. It crawls our customers websites by loading them page by page into the server-side Mozilla. In order to do that it uses jQuery and predefined CSS selectors to find the links in the menus and parse other information out of the pages. The final result is basically a glorified sitemap.
I'd like to keep this modus operandi if possible and continue using jQuery/JavaScript/the DOM to load and parse/access the pages, but it can be wrapped in a framework based on another language such as Java. I considered writing something based on Gecko myself, but that seems a bit over the top, so I'm open for an other suggestions.
As far as HTML crawling/parsing goes:
http://ccil.org/~cowan/XML/tagsoup/
or
http://jsoup.org/

When JEditorPane will not do. JRex, JRex wherefore are thou JRex?

IDEA: Implement a recent web browser into a java application (for saved offline, non server content).
The question is this: can I have a java application implement a webbrowser with jquery / html / css support within a java program?
So I am asking anyone who has played with JRex for advice: I want to know how complicated will it be to integrate an open source webbrowser into java. I am not all that keen on the idea of compiling Mozilla from source build. Is there a ready made compiled version?
Is there a simplified method to have latest compiled version (most current in terms of support for HTML css & javascript), and integrate that into an application?
Also: I appreciate the amount of work required to support for HTML4 nevermind 5, and CSS2 compliance. How close is JRex to that?
Application: My intention with the webbrowser is to render a webpage from offline content. It will not need to be online content, and will simply be for file based displays = e.g. file:///C:...
Does the webbrowser have to be wrapped into a server to function, e.g. to pass files to the browser to render is how complicated? I am not keen to have to implement Jetty or another server type application just for this.
If JRex is not the solution... what then? Is it possible to start a browser implementation within Java and can Java interact with the information and traverse the Dom?
Or alternatively is there .hta equivalent in recent browsers like firefox?
If you need to have the embedded browser interact with your application code, you could try the SWT Browser control, it's actually maintained as opposed to JRex. Browser uses either WebKit or Gecko or embedded IE as appropriate, or lets you choose which one you want, so it should run jQuery and familiar Javascript. And since SWT is a JNI library to begin with they probably already have guidance on how to deploy an app that uses JNI.
You can feed HTML into the control from a string (example) or a java Url - which can point to local files or resource files in your JAR, which I assume will let you split your app into different files.
To call Java code, you need to expose it as Javascript functions. example
To manipulate the HTML from Java code, you need to call Javascript functions from Java. example
To make the previous two tasks easier, you might want to look into a JSON library to simplify passing around complex data.
Does it have to be implemented within a Java program? Could you let the user use the default browser on their machine (ie does it matter what browser)?
If not would use the Java Desktop API.
if (desktop.isSupported(Desktop.Action.BROWSE)) {
txtBrowserURI.setEnabled(true);
btnLaunchBrowser.setEnabled(true);
}
If you are using Java 1.5 try http://javadesktop.org/articles/jdic/

Cross-platform executable/runtime delivery method

I need assistance finding a delivery method that best fulfills the following requirements:
We wish to deliver a single file to my clients.
Clients should be able to launch this file from the operating system shell - much like running an '.exe' on Windows.
After being launched, the program/script should be able to display a window with HTML content. this may be done using a stand alone program, a runtime or by running within a browser.
We need the ability to embed a resource within the delivered file, such as an mp3 file, which i can later extract programmatically.
Optimally, the solution should run on Windows, Mac and Linux machines. Less than perfect cross-platform interoperability is acceptable, but we want as broad a penetration as possible.
Clients should not need to pre-install anything (unless it is done transparently), pre-configure anything, or approve any thing for this to happen.
For example:
We could use a regular executable file, written in C++ to do this, but it will not be cross-platform.
We could use a sliverlight XAP file, an adobe Flex file or a Java JAR, but internet explorer warns users when local content is launched. In addition these approaches mean that we have less than perfect penetration, even though it is acceptable in these cases.
We could use a python (or equivalent) script, but the installed-base (penetration) of the python interpreter is not good enough.
Using a standard HTML is not enough because of the difficulty of embedding resources in it. Embedding Silverlight XAML or uuencoded content in HTML causes IE to display a warning.
Using something along the lines of a jpeg as a delivery method is not rich enough since we need to display HTML.
..but internet explorer warns users when local content is launched..
I don't get it, what's the problem with IE saying "Hey this app is trying to run your files!"
I don't mean you don't have a good reason for this, it is just, I don't get it.
IE will only warn the user if the app has not been downloaded and try to access local resources, for instance if running from an applet or a JNLP like this one:(click on the first orange button you see )
But if the users download the jar and run it from the computer ( double click on it ) the app is local and can run without problems.
The jar file is a zip file after all, so you can attach your mp3 file with it. Double click is supported in the desired platform, and the HTML content could be either a local file ( un-packed along with the mp3 file ) or an internet web page.
Java is preinstalled on those OS already.
"internet explorer warns users when local content is launched"
There's a reason for this. How can they distinguish your excellent, well-behaved, polite application from a virus?
Since the line between your app and a virus is very, very blurry, go with any of Silverlight XAP file, an adobe Flex file or a Java JAR.
The IE business is a good thing, not a bad thing.
You could try using the 'Jetty' application server.
This supposes there is a working java environment on the target machine.
Jetty is java servlet container but it is possible to configure
everything (web server, html templates, applications, etc.) in a
single executable jar, which launches the web server and opens a default page.
Exactly how the jar file is launched will vary from platform to platform
but otherwise the user interface will be identicle, and, as its a java application
you can do pretty much anything one it has started.
Sounds like MIME HTML does exactly what you want - unfortunately, it is not supported by many browsers other than IE.
I'd investigate Adobe AIR. It can display both HTML and Flex content in a desktop application without using a web browser. However this will require installation of the AIR runtime, also I'm not sure if the Linux version is out of the beta stage.
http://www.adobe.com/products/air/
You can also use a binary for each platform.
As per your description the app is very simple, and porting from one platf to another sounds like just matter of re-compile and offer binary based on the dist.
Is this an option?

Categories

Resources