Which option is suitable to replace Java Applet?

Viewed 16463

I would like to replace Java Applet which currently needs to use client's resources, i.e. external readers, and to communicate with a server via socket.

Reason: 1. I have thousands of client machines using this Java Applet program, and most of them are running out-dated JRE. When the Java Applet program is updated / added new features, all client machines will need updating the latest JRE.

Expected Solution:

The Java Applet program would be expected to be replaced by a web-based application, which allows to compile and run source code at client's side such that the new web-based application could still use client's resources and communicate with server via socket.

Can I use JavaScript to achieve it?

I would very appreciate your help/suggestion for this problem. Thank you!

4 Answers

JavaScript is a scripting language that gets evaluated in the browser. I would not describe it as compiling and running but yes, it does mean you can run code in the client and is commonly used to create applications that run in the browser.

There's a staggering amount of frameworks that you can use to write your application. Take a look at the TodoMVC site to see the same TODO app created using several different frameworks.

If you come from Java applets, GWT may be interesting to look at.

If you wish to let the JavaScript client listen for messages from the server, take a look at websockets.

The smart card reader is going to be a problem, though! See Architectures to access Smart Card from a generic browser? Or: How to bridge the gap from browser to PC/SC stack?


By the way:

The real issue with outdated JREs is not that your code will not run on old JREs, you can create perfectly fine applets using java 1.4 or java 5. Any libraries you may need you can deploy alongside your applet. The pain is a security problem. Anything but the latest version Java plugin is getting actively exploited and puts the user at risk. Occasionally, even the latest version is not safe.

try socket.io

I think this is the latest technology you can use to communicate with client browsers. it support the latest browsers and mobile browsers too.

hope this will help you.

Javascript has become very powerful with HTML 5.0. Here is a list of new elements that you can use to access all kinds of resources, including local files, audio, video, GPU rendering (canvas + WebGL) and GPU compute (WebCL). Here are even more things you can do, including database connections and networking. You can even create offline Javascript applications.

jQuery and jQuery layout make robust GUI development a lot easier. Rich tool suites, such as Google Closure offer optimization and a compiler for improving performance and detecting obvious mistakes early in the development process.

W3 offers useful stats for making an informed decision on how many users on average have access to which features. Note that the most annoying guy in that list arguably is IE8 due to it's lack of proper HTML 5.0 support.

In case you want to stick with Java, then one alternative would be to use my http://bck2brwsr.apidesign.org project. It's goal is to create small Java that can run in 100% of modern browsers without any plugin installed.

There are Java bindings to HTML (via knockout - one of the four most popular frameworks for HTML5) and that is why one can code whole business logic in Java and just render it via HTML. Should be enough to replace most of the applet UI.

In addition to that there is an experimental API to render on HTML canvas. People use it to write Java games that run in a pure browser.

There is a simple way to communicate with server via JSON REST API or via WebSockets. A live example is here.

Related