Java 替代小程序的替代技术?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21066333/
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
Alternative technologies to replace applet?
提问by user1636349
I have an (unsigned) applet that let you draw a logic circuit and test it on-screen (a bit like Electronics Workbench), and it then serializes the circuit (the internal form, not the visual representations) and sends it to the server where a bunch of automated tests are run and a performance report is produced. This is a small but crucial part of a much larger web app.
我有一个(未签名的)小程序,可让您绘制逻辑电路并在屏幕上对其进行测试(有点像 Electronics Workbench),然后将电路序列化(内部形式,而不是视觉表示)并将其发送到服务器在这里运行一堆自动化测试并生成性能报告。这是一个更大的网络应用程序的一个小而重要的部分。
However, the latest Java plug-in now says this:
但是,最新的 Java 插件现在是这样说的:
Running unsigned applications like this will be blocked in a future release because it is potentially unsafe and a security risk.
像这样运行未签名的应用程序将在未来的版本中被阻止,因为它具有潜在的不安全性和安全风险。
Now, self-signing it will still apparently work (for now), but then the code runs OUTSIDE the sandbox, which strikes me as a stupid way to do things, even though my code is of course completely bug-free! (Can I interest you in buying a bridge?) Reading further on the Oracle website I see this:
现在,自签名它显然仍然有效(目前),但是代码在沙箱之外运行,这让我觉得这是一种愚蠢的做事方式,即使我的代码当然完全没有错误!(您是否有兴趣购买一座桥?)在 Oracle 网站上进一步阅读我看到:
The platform will notdeny the execution of Java applications... Future update releases may include additional changes to restrict unsafe behaviors like unsigned and self-signed applications."
该平台不会拒绝 Java 应用程序的执行......未来的更新版本可能包括其他更改以限制不安全行为,如未签名和自签名应用程序。”
(Which sounds like it means "Future updates willdeny the execution of Java applications" -- unless you pay money to Thwaite or Verisign on a regular basis AND expose users to code running outside a sandbox.)
(这听起来像是“未来的更新将拒绝 Java 应用程序的执行”——除非您定期向 Thwaite 或 Verisign 支付费用并将用户暴露给在沙箱外运行的代码。)
They also say
他们还说
"Even the smallest changes in user experience are sometimes troublesome".
“即使是用户体验的最小变化有时也会很麻烦”。
(No kidding.)
(不开玩笑。)
"We have considered how changes affect user experience. Given the current climate around Java security in the browser, code signing is a valuable security control for protecting Java users."
“我们已经考虑了变化如何影响用户体验。鉴于当前围绕浏览器中 Java 安全性的气候,代码签名是保护 Java 用户的宝贵安全控制措施。”
Well, I don't see how I can continue using Java under these circumstances. The goalposts have been moved (again), and now I'm looking for a different football team... or more precisely, I'm looking for an alternative technology that will let me continue to do what I do now: drag & drop circuit elements, create connections by dragging between input and outputs or other connections, and finally take the internal form of the diagram and squirt it to the server in a form which can be decoded and exercised, preferably by exactly the same code that created the diagram to avoid versioning headaches. And something which is safe, which can't trash the local filesystem or whatever just because I've signed it.
好吧,我不知道在这种情况下如何继续使用 Java。球门柱已经(再次)移动了,现在我正在寻找不同的足球队......或者更准确地说,我正在寻找一种替代技术,让我继续做我现在所做的事情:拖放电路元素,通过在输入和输出之间或其他连接之间拖动来创建连接,最后采用图表的内部形式并将其以可以解码和执行的形式喷到服务器,最好使用与创建图表完全相同的代码以避免版本问题。还有一些安全的东西,它不能仅仅因为我已经签名而破坏本地文件系统或其他任何东西。
Can anyone suggest where I should be looking next, now that Oracle has made my life a nightmare?
既然甲骨文让我的生活变成了一场噩梦,有人能建议我下一步应该去哪里寻找吗?
回答by Andrew Thompson
(Which sounds like it means "Future updates will deny the execution of Java applications" -- unless you pay money to Thwaite or Verisign on a regular basis AND expose users to code running outside a sandbox.)
(这听起来像是“未来的更新将拒绝 Java 应用程序的执行”——除非您定期向 Thwaite 或 Verisign 支付费用并将用户暴露给在沙箱外运行的代码。)
A signed applet launched using JNLP can still be sand-boxed.
使用 JNLP 启动的签名小程序仍然可以被沙盒化。
But if you really wish to avoid it..
但如果你真的想避免它..
I think what you described can be provided using JavaScript for the logic and and an HTML 5 canvas
for the rendering.
我认为您所描述的可以使用 JavaScript 提供逻辑和 HTML 5canvas
进行渲染。
I would avoid Flash, since it is also susceptible to security bugs. It would be like digging yourself a brand new hole to get trapped in.
我会避免使用 Flash,因为它也容易受到安全漏洞的影响。这就像给自己挖一个全新的洞,让自己陷入困境。
回答by watery
I can't comment on what you found about applets, since I never wrote one.
我无法评论您对小程序的发现,因为我从未写过。
If you want to move away from them, maybe your only option (while staying with Java) is go for web applcations, where the code is most on server-side and you interact with your software directly in your browser. On the client-side javascript (and js-related libraries like JQuery) is used, though I can't elaborate about it more since I'm don't know the Java EE stack very well yet.
I'm not sure if you can get 100% the same user experience as you currently have in your applet, above all for an electronics application. But it may offer the highest code-reuse of most of your Java classes.
如果您想摆脱它们,也许您唯一的选择(同时使用 Java)是使用 Web 应用程序,其中代码最集中在服务器端,您可以直接在浏览器中与您的软件进行交互。在客户端使用了 javascript(以及与 js 相关的库,如JQuery),但我无法详细说明它,因为我还不太了解 Java EE 堆栈。
我不确定您是否可以获得 100% 与您目前在小程序中相同的用户体验,尤其是电子应用程序。但它可以为您的大多数 Java 类提供最高的代码重用率。
I've used Vaadin, it's a framework that moves almost all your coding to the server-side (you only need to code the client side if you want to create addons). I've heard about Zktoo, but I've never used it, so I can't say anything about it.
我使用过Vaadin,它是一个框架,可以将您几乎所有的编码移动到服务器端(如果您想创建插件,您只需要在客户端编码)。我也听说过Zk,但我从来没有用过它,所以我不能说什么。
回答by Mathias Zaja
You can still run unsigned java applets in your web pages if you block your Java plugin in the browser to the version SE 7 U11 (jre-7u11-windows-i586.exe) Of course you will have to block automatic Java update with "C:\Program Files (x86)\Java\jre7\bin\javacpl.exe" I hop you can survive for a while this way, before you find an alternative to JAva applet. In HTML5 the tag to call an apllet is now object and the syntax is a bit different:
如果您将浏览器中的 Java 插件阻止到 SE 7 U11 (jre-7u11-windows-i586.exe) 版本,您仍然可以在网页中运行未签名的 Java 小程序 当然,您必须使用“C”阻止自动 Java 更新:\Program Files (x86)\Java\jre7\bin\javacpl.exe” 我希望你可以这样生存一段时间,然后你才能找到 Java 小程序的替代品。在 HTML5 中,调用 apllet 的标签现在是对象,语法有点不同:
<object codetype="application/java"
classid="yourApplet.class"
codebase="http://www.yourserver ..."
archive="YourJarFile.jar"
width="x" height="y">
<param name="paramName1" value="paramValue1"/>
<param name="paramNamei" value="paramValuei"/>
</object>