我想方便地展示我的应用程序,而无需携带笔记本电脑或分发混淆的 Java 应用程序。
有没有一种简单的方法可以在浏览器中查看我的 Swing 应用程序。我不一定需要命令按钮才能工作(但如果需要的话那就太好了),我只想从互联网上的任何地方查看像素。我有从 JChart2D 构建的图表。
编辑:屏幕会在可配置的时间段后更新,通常为 15 秒,但如果桌面每 15 秒更新一次,而浏览器图像的更新速度要慢得多,例如 1 分钟,那就没问题了。
编辑:我拥有的主要是一个桌面应用程序,因为它是一个桌面应用程序,可以满足 98% 的要求,但如果我可以看到它或远程使用它而不需要重写,这会给我带来额外2%(看到它1%,使用它1%)。
I want to show my app conveniently without the hassle of carrying a laptop or distributing an obfuscated Java app.
Is there an easy way to view my Swing app in a browser. I do not necessarily need the command buttons to work (but it would be nice if they did), I just want to see the pixels from anywhere on the internet. I have graphs built from JChart2D.
Edit: The screen updates after a configurable period and 15 seconds is typical but if the desktop updates every 15 seconds and the browser image at a much slower rate, say, 1 minute, that would be okay.
Edit: What I have is primarily a desktop app in that it being a desktop app satisfies 98% of the requirements but if I can see it or use it remotely without a re-write that would give me the extra 2% (see it 1%, use it 1%).
发布评论
评论(5)
为此,最近的 Webswing 可能是完美的。看起来功能齐全。有一些小故障,我想念光标。唉,无论您是否愿意,远程应用程序也会显示在服务器上。
For that purpose, the recent Webswing may be perfect. It seems fully functional. There are some glitches and I miss the cursors. Alas, the remote applications are displayed on the server, too, whether you want it or not.
我不认为我会推荐这样做(因为它具有安全隐患和防火墙问题),但可以使用远程 X11 服务器运行 Java / Swing 应用程序。
以下是一些相关链接:
但您的 Linux 文档中可能有更多最新信息。
另一个想法是制作一部演示电影。
I don't think I would recommend this (because it has security implications and firewall issues) but it is possible to run a Java / Swing application using a remote X11 server.
Here are some relevant links:
but there is probably more uptodate information in your Linux documentation.
Another idea is to make a demonstration movie.
解决方案并不多,但最简单的方法是 JNLP。
JNLP 是一种基于 XML 的技术,用于通过 Web 启动 Java 可执行文件。试想一下,您可以指定应用程序中的类路径资源(图像、JAR 文件、属性、文件等),这些资源分散在 Web 上并给出它们的 URL,而不是像普通 Java 应用程序那样依赖本地文件系统。此功能使您能够通过声明文件在 Web 上的位置来自动部署应用程序(即安装所需的应用程序文件并正确启动它们)。而且它比小程序要容易得多,因为浏览器的严格权限会给您带来很多麻烦。
JNLP 的示例位于此处和此处。
There is not many solutions for it but this easisest way is JNLP.
JNLP is an XML-based technology for launching Java executables over the Web. Just imagine that you could specify the classpath resources in your application (images, JAR files, properties, files, etc.), scattered over the Web and giving their URLs, instead of relying on the local file system as normal Java applications do. This feature would give you the capability of deploying your application automatically (that is, installing needed application files and launching them properly) just by declaring where your files are on the Web. And it is far easier than Applets which can create a lot of troubles to you because of strict permissions at browser.
An example of JNLP is here and here.
另一种可能性(不一定是好的,但易于实现)可能是使用
java.awt.Robot
类。使用此类,您可以使用
#createScreenCapture(...)
定期拍摄屏幕快照,并使用javax.imageio.ImageIO
。然后就可以直接创建一个显示该图像并定期自动刷新的 HTML 页面。有点复杂和迂回,但可以让您重用现有的基础设施。
One other possibility (not necessarily a good one, but easy to implement) might be to use the
java.awt.Robot
class.Using this class, you could periodically take a snapshot of the screen, using
#createScreenCapture(...)
, and write this out to disk usingjavax.imageio.ImageIO
.It would then be straightforward to create an HTML page that displayed this image, and auto-refreshed periodically. A little bit complicated and circuitous, but may let you re-use existing infrastructure.
VNCj(官方页面,SourceForge) 是一个较旧的项目,它在 VNC 服务器上提供 AWT 的实现。 Swing 在此之上运行。与 WebSwing 不同,运行 VNCj 时服务器上不会出现 UI。
VNCj (official page, SourceForge) is an older project which provides an implementation of AWT on a VNC server. Swing runs on top of that. Unlike WebSwing, no UI appears on the server when running VNCj.