Usability of Java applets on the web

前端 未结 7 1513
情歌与酒
情歌与酒 2021-01-14 19:40

For our eLearning project in our university, we are using Java applets to show some interactive stuff (like some interactive function plotting or some simple question/answer

7条回答
  •  无人共我
    2021-01-14 20:04

    1. "A Java applet take ages to load."

    Not really. Whey you load your first applet, you also load the JVM which, unlike the JavaScript engine, is not loaded when you start your browser. The JVM startup time are not longer than the JavaScript startup time, but the last one are hidden in the browser startup time... There are a project called Jigsaw which will split the current JVM into modules and make this initial startup much faster, and are scheduled for Java 9.

    2. "The browser (or at least the tab in Chrome) gets very slow esp while loading the applet but also afterwards."

    While loading the JVM, it's natural that things slow down. However, if the browser is slow afterwards, you probably have some bug in your applet that use excessive CPU time. This isn't any different from JavaScript which also can make the browser very slow. You may need to profile your applet in order to figure out where your resources go. I do have problems with Chrome, but its support for applets are known to be crappy...

    3. "The Java applet looks different on every system."

    If you use Swing with a non-native look and feel it does not. Personally I prefer the modern Nimbus look and feel.

    How to set Nimbus look and feel in main

    4. "Sometimes the memory usage is incredibly high (but not always)."

    Profile your code, you are probably doing excessive memory allocations. Read up on object pools and other methods to decrease memory fragmentation. This are usually the sign of a badly coded Applet, rather than a problem with the Applet technology.

    5. "When loading a page with multiple applets, the chances become very high that the browser crashes and or multiple applets don't load correctly. Also the whole operating system gets very slow."

    Personally I would not have multiple applets on a page. See if you can merge them. Some browsers have very bad support for this. But more importantly it's not very user-friendly even when the technology do not mess it up.

    6. "Sometimes, the Java applet doesn't load in browser X but in browser Y"

    This is a known problem with modern browsers that tend to not support plugins well. This are actually the same problem as number 5. This problem are much more rare when you only use a single applet on your page.

    7. "Sometimes, the applet stays blank when I switched to another tab and return back. Sometimes it at least takes a very long time until it shows up again."

    Same problem as 5 and 6. The plugin code (NPAPI) haven't been modernized to properly support plugins. The browser is not telling the plugin that it must redraw it contents properly. Alternatively it may have crashed. This problem are also more rare if you only use a single applet.

    8. "It eats up all the CPU. Even after I have closed all tabs with the applets. I have to quit the browser to resolve this."

    Applets do not close when you close the tabs. They close when the applet exits, which you need to do in your code. Your code has to listen to some event, clean up, and exit. I don't remember the code for this as I usually copy-paste it. Also it's possible that AWT/Swing freaks out if you don't shut it down when its window resource dies...

    On some of this you are right, and on others you have problems because you are using outdated libraries (like AWT or Swing with default look and feel) or do not understand how to manage the applet life-cycle.

提交回复
热议问题