哪个选项适合替换Java Applet?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20394451/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-13 01:37:33  来源:igfitidea点击:

Which option is suitable to replace Java Applet?

javajavascripthtmlapplet

提问by Nam Truong

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.

我想替换当前需要使用客户端资源(即外部阅读器)并通过套接字与服务器通信的 Java Applet。

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.

原因:1. 我有数千台客户端机器在使用这个Java Applet 程序,其中大部分都运行过时的JRE。当 Java Applet 程序更新/添加新功能时,所有客户端机器都需要更新最新的 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.

Java Applet 程序有望被基于 Web 的应用程序取代,该应用程序允许在客户端编译和运行源代码,以便新的基于 Web 的应用程序仍然可以使用客户端的资源并通过套接字与服务器通信。

Can I use JavaScriptto achieve it?

我可以使用JavaScript来实现吗?

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

我非常感谢您对此问题的帮助/建议。谢谢!

回答by Ipis Boomz

try socket.io

试试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.

希望这会帮助你。

回答by Domi

Javascript has become very powerful with HTML 5.0. Hereis 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). Hereare even more things you can do, including database connections and networking. You can even create offline Javascript applications.

Javascript 在HTML 5.0 中变得非常强大。以下是可用于访问各种资源的新元素列表,包括本地文件、音频、视频、GPU 渲染 (canvas + WebGL) 和 GPU 计算 (WebCL)。下面是更加的事情可以做,包括数据库连接和网络。您甚至可以创建离线 Javascript 应用程序

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

jQuery 和jQuery 布局使强大的 GUI 开发变得更加容易。丰富的工具套件(例如Google Closure)提供优化和编译器,用于在开发过程的早期提高性能和检测明显错误。

W3 offers useful statsfor 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.

W3 提供了有用的统计数据,可以就平均有多少用户可以访问哪些功能做出明智的决定。请注意,该列表中最烦人的可能是 IE8,因为它缺乏适当的 HTML 5.0 支持。

回答by flup

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.

JavaScript 是一种在浏览器中进行评估的脚本语言。我不会将其描述为编译和运行,但是是的,它确实意味着您可以在客户端运行代码,并且通常用于创建在浏览器中运行的应用程序。

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

您可以使用数量惊人的框架来编写应用程序。查看TodoMVC站点以查看使用多个不同框架创建的相同 TODO 应用程序。

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

如果您来自 Java 小程序,GWT 可能会很有趣。

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

如果您希望让 JavaScript 客户端侦听来自服务器的消息,请查看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?

不过,智能卡读卡器将是一个问题!请参阅 从通用浏览器访问智能卡的架构?或者:如何弥合从浏览器到 PC/SC 堆栈的差距?



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.

过时 JRE 的真正问题不在于您的代码不能在旧 JRE 上运行,您可以使用 java 1.4 或 java 5 创建完美的小程序。您可能需要的任何库都可以与您的小程序一起部署。痛苦是一个安全问题。除了最新版本的 Java 插件之外的任何东西都被积极利用,并使用户处于危险之中。有时,即使是最新版本也不安全。

回答by Jaroslav Tulach

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

如果您想坚持使用 Java,那么另一种选择是使用我的http://bck2brwsr.apidesign.org项目。它的目标是创建小型 Java,无需安装任何插件即可在 100% 的现代浏览器中运行。

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.

有到 HTML 的 Java 绑定(通过淘汰赛- HTML5 的四个最流行的框架之一),这就是为什么可以用 Java 编写整个业务逻辑并通过 HTML 呈现它的原因。应该足以取代大部分的小程序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.

除此之外,还有一个在 HTML 画布上呈现的实验性 API。人们使用它来编写在纯浏览器中运行的 Java 游戏。

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

有一种通过 JSON REST API 或 WebSockets 与服务器通信的简单方法。一个活生生的例子在这里