Java 小程序在 Web 上的可用性 [英] Usability of Java applets on the web

查看:33
本文介绍了Java 小程序在 Web 上的可用性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于我们大学的电子学习项目,我们使用 Java 小程序来展示 Ilias 学习单元内的一些交互式内容(例如一些交互式函数绘图或一些简单的问答系统或其他交互式元素以及它们的任意组合).

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 system or other interactive elements and any combination on those) inside of Ilias learning units.

我们决定使用 Java 是因为我们想要一个开放的解决方案(当时 HTML5 还没有真正可用,Flash 过去和现在都不是一个选择).

We decided for Java because we wanted an open solution (and HTML5 was not really available at that time and Flash was and is not really an option).

现在,几年后,我真的觉得 Java 并不能真正用于网络.主要是因为有很多问题,我无法真正解决所有情况.

Now, a few years later, I really got the feeling that Java is not really usable for the web. Mostly because of a lot of problems I haven't really been able to fix for all cases.

那么,我的问题是:Java 是不是不适合网络,还是我做错了什么?你能指出我如何解决这些问题吗?

So, my question: Is Java just not the right thing for the web or am I doing something wrong? Can you point out how I could solve these problems?

当时遇到的问题:

  • Java 小程序需要很长时间才能加载.即使是一个非常简单的小程序,有时也需要一分钟左右的时间来加载.这是为什么?Java 框架真的比 Qt 或其他框架大得多吗?还是虚拟机这么大?还是虚拟机这么慢?

  • A Java applet take ages to load. Even if it is a very simple small applet, it sometimes takes about a minute to load. Why is that? Is it really that the Java framework is so much bigger than Qt or other frameworks? Or is the VM so big? Or is the VM so slow?

浏览器(或至少 Chrome 中的选项卡)在加载小程序时变得非常缓慢,尤其是在加载之后.

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

Java 小程序在每个系统上看起来都不一样.UI 控件完全不同,行为也略有不同.有时它是原生的外观(或一种),有时它完全是自己的.此外,字体大多不同,通常支持不同的 Unicode 字符子集.这对我们来说是一个真正的问题,因为我们经常使用 Unicode 来表示数学符号,而且我们收到很多报告说某些符号对某些人不起作用.此外,由于每个系统上的字体大小不同,我收到报告称该文本是为少数人剪掉的(或在 JLabel 中用..."缩短).我现在通过在 JAR 中包含一个 TTF 来解决这个问题.这主要是有效的.有时我还是会得到这些……"即使使用独特的字体也能报告.

The Java applet looks different on every system. The UI controls are totally different and also behave slightly different. Sometimes it's the native look (or kind of it), sometimes it's completely something own. Also the font is mostly different and often supports a different subset of Unicode characters. This is a real problem for us because we use Unicode a lot for math symbols and we got a lot of reports that some symbols don't work for some people. Also as the font has different size on each system, I got reports that the text is cut out for a few people (or shortened by "..." in a JLabel). I have gotten around this problem now by including a TTF in the JAR. That works mostly. Still sometimes I get these "..." reports even with the unique font.

有时内存使用率非常高(但并非总是如此).

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

加载包含多个小程序的页面时,浏览器崩溃和/或多个小程序无法正确加载的可能性非常高.整个操作系统也变得很慢.

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.

有时,Java 小程序不会在浏览器 X 中加载,而是在浏览器 Y 中加载.在重新加载或重新启动浏览器/系统时单击几次后,该行为可能会改变.例如,似乎小程序在 Firefox 中加载的可能性更高(也不总是,但大多数情况下,至少在重新加载时单击一两次之后),而在 Chrome 上的可能性较小(但如果我幸运的话,它有时也可以工作).根据系统的不同,效果最好的浏览器可能会有所不同.虽然从来没有完美的浏览器.这种行为适用于我们测试过的所有系统(不同的 Linux 发行版,包括 32 位和 64 位、Windows XP/Vista/7、Mac OS X).

Sometimes, the Java applet doesn't load in browser X but in browser Y. After clicking a few times on reload or restarting the browser/system, that behavior may switch. For example, it seems that chances are higher that the applet load in Firefox (also not always, but mostly, at least after clicking one or two times on reload) and less likely on Chrome (but if I am lucky it also works sometimes). Depending on the system, it may be different browsers which work best. Though there is never a browser which works perfect. This behavior is on all the systems we have tested (different Linux distributions, both 32bit and 64bit, Windows XP/Vista/7, Mac OS X).

有时,当我切换到另一个选项卡并返回时,小程序会保持空白.有时至少需要很长时间才能再次出现.

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.

它吃光了所有的 CPU.即使在我用小程序关闭了所有标签之后.我必须退出浏览器才能解决这个问题.

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.

我们遇到这些问题的一些示例:

Some examples where we have these problems:

如果您查看这些示例,Java 的替代解决方案是什么?我在最近的浏览器中考虑过 HTML + JavaScript(如果我们告诉我们的用户他们应该使用 WebKit 左右的浏览器),尽管我认为其中一些示例可能很难实现(或者至少比在 Java 中更难).

If you look at these examples, what would be a good alternative solution to Java? I thought about HTML + JavaScript with recent browsers (it is not really a problem if we tell our users that they should use WebKit based browsers or so), although I think that some of these examples might be very hard to implement (or at least harder than in Java).

推荐答案

Java 小程序在本世纪初是现代的.目前只有少数网站使用 Java 小程序,这可能是浏览器支持不是最佳的原因之一.

Java applets were modern at the beginning of this century. There are only a few sites using Java applets today and this may be one of the reasons why the browser support is not optimal.

从我在浏览器卡住之前看到的情况来看,您的小程序似乎只是在绘制各种图表.

From what I've seen before my browser got stuck, your applets seem to be just drawing various charts.

我建议尝试使用一种专注于绘制图表的现代 JavaScript 库:http://javascript.open-libraries.com/utilities/chart/20-best-javascript-charting-and-plotting-libraries/

I would suggest trying one of the modern JavaScript libraries which focus on drawing charts: http://javascript.open-libraries.com/utilities/chart/20-best-javascript-charting-and-plotting-libraries/

或者,如果您需要比库提供的更多选项并且您不太关心跨浏览器的兼容性,您可以使用 HTML5 元素和 SVG - 除 Internet Explorer 外的所有浏览器都支持这些.

Alternatively, if you need more options than the libraries offer and you do not care much about cross-browser compatibility, you may use the <canvas> HTML5 element and SVG - all browsers except for Internet Explorer have decent support of these.

如果您不要求图表具有交互性,您可以使用 PHP、Ruby、Python、Java 或其他工具在服务器上呈现它们,并将它们作为纯图像发送到浏览器.

If you do not require the charts being interactive, you can render them on the server using PHP, Ruby, Python, Java, or whatever and send them as plain images to the browser.

如果您需要表达数学表达式,请考虑 MathML 或可能在通过服务器脚本飞行.

If you need to express mathematical expressions, consider MathML or plain images possibly rendered on the fly by a server script.

这篇关于Java 小程序在 Web 上的可用性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆