Where are the Java Applets?

April 9, 2008

I’ve often asked myself why Java Applets are not more prevelant. HTML is relatively static. Even with CSS, web pages comprised simply of HTML are not very interactive, especially compared to desktop applications.

The developer community is very creative. A variety of technologies, methods, and tools have been utilized to bring life to HTML. Flash, Javascript, AJAX, and SVG are growing in popularity and add a richness and interactivity to web based apps that approaches desktop apps.

Why has the Java applet been left in the dust? I have a few explanations.

First, there is a lack of understanding in the proper usage of the Java applet on a web page. A web page is not a desktop application and the techniques of building Java standalone (desktop) applications do not carry over to web apps. Java user interface components and frameworks have advanced nicely over the years. SWT and Swing can be used to create desktop apps that are as clean, crisp, and visually appealing as native desktop apps. However, SWT and Swing have little use in a Java applet. And that is the approach many Java developers take.

The correct mindset is that of the Flash or browser plugin developer. At their disposal is a rectangular region of the page. They can do whatever they want in that space. To use Swing or SWT there – as it would be used on in a desktop app – is generally inappropriate.

Second, web developers that focus on look and feel are typically not software engineers. Software engineers gravitate towards Java. Designers gravitate towards things like Flash, CSS, and AJAX. While beautiful UIs can be built with Java, it is simply not the tool of the designer. Perhaps JavaFX will address this.

Finally, I believe the use of Java applets are underestimated. There are web sites that utilize Java applets, but they are not easily recognized. Applets don’t look like Swing or SWT apps, so they go unnoticed. These sites are using applets properly. They are not trying to stick a Java desktop-like component into the middle of a web page.

I would like to see Java applets utilized more. From the perspective of a software engineer, I prefer the Java applet. It provides a great deal of control, allows me to do quite a bit (in a rectangular region of a web page), is very robust, and performs extremely well. I generally avoid heavy Javascript because it is unpredictable across browsers. I’ve noticed that sites utilizing heavy Javascript tend to also have performance problems. So, while Java applets have plenty of advantages, it simply may not be the tool of choice.

RELATED
Applets reloaded

Entry Filed under: Software Development. Tags: , .

9 Comments Add your own

  • 1. PermaGen  |  April 9, 2008 at 4:27 am

    Is there any document explaining what happens when an applet is started? Is a special Classloader used? What will happen if I close the browser page or press the browsers reload button?

    In case I place a JPanel into the JApplet…what will happen to it after a reload? What will happen to static Threads after a reload…will they be interrupted? Will JTextPanes work after a reload?

    etc…the complete technology behind Applets is documented nowhere. There are no best practices how to write an Applet. How to write for example an applet that survives a reload. How to correctly dispose of an Applet, etc.

    Reply
  • 2. Mike Dee  |  April 9, 2008 at 7:26 am

    Some of the behaviors you mention are well understood- if not well documented. Reloading a page, for example, is well understood.

    Some of the problems you mention demonstrate a misuse of Java in an applet. I talked about this in the article. JTextPanes probably should not be used in an applet. The browser already provides a form field. One could write a Java applet that easily communicates with form fields on a page. Communications between a page, its elements, and a Java applet is well documented and has been for a long time.

    Think of the browser as your operating system. Java, as a language, provides more capabilities than the browser allows. As a programmer or designer, it is your job to figure out how to work well within the environment.

    The problem of Java providing more capabilities than its environment exists in J2EE too. In servlets, the use of member fields is problematic. A servlet must be written with the knowledge that its method to process a request is invoked as thread and use of member fields has side effects that are not prevented by the Java language. Similarly, EJBs should not use threads. The container creates a new EJB for each thread, thus providing a better alternative to threads. Use of threads in an EJB is simply misuse of threads in that environment. The desire to use threads in an EJB often times indicates the need for JMS.

    Also, many of the problems you mention exist for other browser plugins and techniques. For example, how does Flash work with the browser’s back and forward buttons? Frames have problems too (including IFRAMES) as well as AJAX and techniques that use heavy Javascript. No technology or method is foolproof running in a browser. And I don’t see that as an argument against Java applets, especially when it offer so many advantages.

    Reply
  • 3. PermaGen  |  April 9, 2008 at 1:56 pm

    I agrre with a lot what you said but also disagree on the point that one shouldn’t use Swing.

    If one doesn’t use Swing once can completely skip Applets and directly use Ajax (unless security is paramount).

    If you know what happens in the Applet lifecycle please let everybody know.

    1. How exaclty are classes loaded in an Applet (special Classloader). What effect does it have on the lifecycle?
    2. What happens when I push the reload button? We all know that stop/destroy/init/start are called. But why break threads sometimes? What happens to Panels one embedded in JApplets contentpane?
    3. Why is there no best practices for Applets that state what you claim…don’t use Swing, don’t use Threads, etc. Why is JApplet there in the first place if Swing is forbidden?
    4. Could one construct a special framework that automatically removes the complete Applet (objects, class-objects and the classloader itself) from memory when destroy is called()?

    etc.etc.etc.

    Reply
  • 4. Ian  |  April 9, 2008 at 6:37 pm

    Yeah, Sorry. I just don’t think Applets should be used.

    They have a (very) slow start-up (JVM initialisation) time and at best mediocre browser support.

    I’ve implemented Applets before and had no-end of compatibility issues between *(sub) versions* of Java – let-alone different OS’s.

    We switched to Flash and it was about 30% quicker to develop in and compatible with all browsers we tested it on and our clients tested it on. Comparatively, it was a seamless experience.

    I’ll never use Applets again.

    Reply
  • 5. Mike Dee  |  April 9, 2008 at 9:45 pm

    Good questions and I don’t have specific answers to each question.

    Obviously a JFrame is useful in an applet. But I don’t believe heavy use of Swing components as appropriate in an applet. In other words, taking a full fledged Java application and plopping it in the middle of a web page is not a good idea. I’ve seen it. When done, it is impressive. But I don’t see the point.

    Just because something is there (a feature of the language), doesn’t mean it should be used. The environment must be considered. Take the EJB and servlet examples I provided. Yes Java can do threads. Use of thread in an EJB is simply not appropriate.

    Each case in which an applet is used is different. The situation must be considered. Maybe an architecture change is the solution. Or maybe an applet is simply not appropriate.

    Everyone wants their web app to be more interactive – like a desktop app. Maybe current browsers simply can’t accomodate that.

    Reply
  • [...] Where are the Java Applets [...]

    Reply
  • 7. Moritz Petersen » Blog Archive » Java Applets  |  April 10, 2008 at 2:50 am

    [...] was even more surprised, when I read about applets in very recent blog posts at dzone and Mikes blog. Although I don’t believe that Java applets will have a popular comeback, I would [...]

    Reply
  • 8. Chris  |  April 15, 2008 at 2:40 pm

    Excellent post. I was actually thinking about this the other day, when looking into a tutorial on browser based games. The tutorial I was viewing was educating the user through applets. A lot of the things mentioned seemed to be well suited to applets, but I don’t really see applets outside of the old Yahoo Games website, and those often crash my browser. Still, I think it would be interesting if people started working with applets more. Do new versions of java increase applet performance?

    As for Swing…I avoid it at all costs.

    Reply
  • 9. Mike  |  June 26, 2008 at 8:02 am

    I’d like to post, what I consider, good examples of applets. These are not full fledged applications running in a browser, but things you may do with Javascript, Ajax, or Flash.

    Here is one:

    http://radar.weather.gov/radar.php?rid=BOX&product=N0Z&overlay=11101111&loop=yes

    Reply

Leave a Comment

Required

Required, hidden

Some HTML allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <pre> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Trackback this post  |  Subscribe to the comments via RSS Feed


Categories

Recent Comments

SaaS: More Power To … on Where is the modern day e…
Mike on Where are the Java Applet…
Chris on Where are the Java Applet…
Moritz Petersen … on Where are the Java Applet…
{ heli’s code } … on Where are the Java Applet…

RSS Twitter Timeline

 

April 2008
S M T W T F S
« Mar   May »
 12345
6789101112
13141516171819
20212223242526
27282930  

Archives