是否可以使用 Java 后端创建桌面应用程序?网络技术用户界面

发布于 2024-09-12 22:52:31 字数 1436 浏览 6 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

凉世弥音 2024-09-19 22:52:31

首先,这是可能的。如果您正在寻找示例,请检查 http://wiki.eclipse.org/Hudson-ci/ Meet_Hudson
如果你深入研究他们的代码,你可以获得基本的架构。它不使用任何嵌入式数据库。
您说您的应用程序将始终处于离线状态,在这种情况下,我建议您使用 Eclipse 插件开发等技术来选择纯桌面应用程序。

如果您已经下定决心,根据我对类似应用程序的经验,这里有一些要点可以帮助您,

  1. 尽管您的应用程序处于离线状态(我假设,您的应用程序不需要连接到任何用例的任何服务器,但用户计算机可以访问互联网),您需要将更改(例如,html 或 jsp 页面中的更改)/错误修复透明地交付给最终用户。 JNLP/Java Web Start 非常适合于此。

  2. 如果您打算采用 JNLP 方式安装,则启动程序应该负责最终用户计算机上的嵌入式数据库安装和端口(这比看起来的问题要大)。

  3. 此外,如果您通过 JNLP 启动服务器(在我的例子中是 Jetty),您将遇到由于权限问题而导致的类加载错误。准备好挖掘服务器代码。我很久以前就完成了,现在没有代码来指出确切的问题。

  4. 在安装过程和应用程序启动过程中显示进度条。您的战争部署需要一些时间,并且用户需要了解应用程序正在启动。您最终将编写一些 swing UI。

  5. 应用程序启动后,在用户系统的默认浏览器中自动启动应用程序的 URL。您不需要嵌入式浏览器。检查 http://java.sun .com/developer/technicalArticles/J2SE/Desktop/javase6/desktop_api/

  6. 我使用MySql作为嵌入式数据库。检查在java桌面应用程序中嵌入mysql。它对我有用,我没有遇到任何问题。

First of all, it is possible. If you are looking for example, check http://wiki.eclipse.org/Hudson-ci/Meet_Hudson.
You can get basic architecture if you dig into their code. It does not use any embedded db.
You are saying your application will always be offline, in that case I suggest you to go for pure desktop application using technologies like Eclipse plugin development.

If you already made up your mind, here are some points that can help you based on my experience with similar application,

  1. Although your application is offline(I assume, your application need not connect to any server for any use case but the user machine can access internet ), you need to deliver changes(for example, change in html or jsp page )/bug fixes transparently to end user. JNLP/Java web start is a good fit for this.

  2. If you are going for JNLP way of installing, you launcher should take care of embedded db installation and ports at the end user machine(this is big problem than it appears).

  3. Also if you are launching server(in my case, Jetty) through JNLP, you will come across Class loading errors due to permission issues. Be prepared to dig through server code. I have done it long time ago and I do not have code now to point exact issues.

  4. Show progress bars during installation process and during your application startup. Your war deployment takes some time and user needs some of knowing that application is startup is in progress. You will end up writing some swing UI.

  5. Launch URL of the application automatically in default browser of the user system, after application startup. You do not need embedded browser.Check http://java.sun.com/developer/technicalArticles/J2SE/Desktop/javase6/desktop_api/.

  6. I used MySql as embedded data base. Check Embedding mysql in java desktop application. It worked for me, I did not come across any problems.
岛歌少女 2024-09-19 22:52:31

是的,这是可能的。请参阅 https://github.com/jreznot/electron-java-app 演示。在那里,您将找到一种在 Java 上构建基于 Electron 的应用程序的简单方法,无需编译为 JS,只需使用 Vaadin UI 嵌入 Jetty 实例内的 Java 应用程序即可。

Yes, it is possible. See https://github.com/jreznot/electron-java-app demo. There you will find an easy way to build Electron based application on Java, without compilation to JS, just Java application inside of embedded Jetty instance with Vaadin UI.

披肩女神 2024-09-19 22:52:31

你说得对,如果你自己开发一个项目,java就很棒。

服务器端编码可以使用 Spring(对于 MVC、数据库等...非常丰富且轻量级的框架,易于学习和理解)和 hibernate(用于数据库处理的 ORM 框架,为任何数据库服务器提供方言)来完成。

对于 UI,您可以使用 Spring MVC 或 JSF 或 GWT 或 javaFX。 JavaFX提供JNLP下载,它在java上运行,无需浏览器。检查更多 JavaFX 示例的链接。 http://javafx.com/samples/

所以这取决于你,你想在 UI 端使用什么。如果您更喜欢 Web UI(我的意思不是 javaFX),那么您可以有很多选择。

对于 Ajax,您将拥有支持简单 ajax 的库。像 DWR (Easy Ajax, JS to JAVA) 和许多其他 JS 库,如 yahoo、jQuery 等都可以使用。

希望这有帮助。

You are truly right, java is great if you are developing a project by self.

Server side coding can be done using Spring (For MVC, Database etc...Very rich and ligthweight framework, easy to learn and understand) with hibernate(ORM framework for Database handling, provides dialects for any Database server).

For UI, you can use Spring MVC OR JSF OR GWT OR javaFX. JavaFX provides JNLP download, which runs on java and without browser. check the link for more JavaFX samples. http://javafx.com/samples/

So its on you, what you want to use for UI side. If you prefer web UI (Not javaFX i mean) then you can have many options.

For Ajax, you will have libraries which support easy ajax. like DWR (Easy Ajax, JS to JAVA) and many other JS libraries like yahoo, jQuery etc.. can be used.

hope this helps.

来日方长 2024-09-19 22:52:31

恕我直言,运行网络服务器只是为了使用 js 和 ajax 等创建桌面应用程序的整个想法是可怕的......我听说过 Apple-creator Titanium 允许使用网络技术创建跨平台应用程序。还有其他几个类似的程序。

我认为你最终会更好地购买一个好的 wyswing Swing 设计工具用于 java ui,这将花费你几百美元,但会为你省去很多很多开发麻烦。很难相信布置一个漂亮的桌面应用程序比布置网页更复杂。

IMHO the whole idea of running a web-server just to create a desktop app with js and ajax and stuff is horrible... I heard about Apple-creator Titanium which is allows to create crossplatform apps using web techniques. There are couple other similar programs as well.

I think you'll end up better buying a good wyswing Swing design tool for java ui which will cost you couple hundred bucks but will save you lots and lots development trouble. It is very hard to believe that laying out a nice desktop app is more complicated than laying out a web page.

预谋 2024-09-19 22:52:31

我没有得到嵌入的jetty/tomcat部分。您希望桌面应用程序运行与数据库通信的嵌入式服务器吗?那么每个桌面应用程序都会打开一个数据库连接?

为什么不使用 Java 桌面应用程序将 HTTP 请求发送到连接到数据库并处理请求的 JavaEE 服务器?所以基本上,Java 客户端(可以根据开发人员的能力而丰富)取代浏览器。这为您提供了更多的可扩展性等。

我们有一个使用开发的类似(尽管更复杂)的产品
- 桌面上的 Swing + Apache Commons HttpClient。这会向服务器发出带有序列化二进制数据的 HTTP POST 请求。
- 在 Web 容器中运行的调度程序 Servlet,它在服务器上重新创建 Java 对象并执行请求。

I didn't get the embedded jetty/tomcat part. You want the desktop app to run an embedded server that talks to the database? So each desktop app would open a DB connection?

Why not have a Java desktop app that sends HTTP requests to a JavaEE server that connects to the DB and processes the requests? So basically, a Java client (which could be as rich as your developers can make it) replacing a browser. This gives you a lot more scalability, etc.

We have a similar (albeit much more complex) product developed using
- Swing + Apache Commons HttpClient on the desktop. This makes an HTTP POST request with serialized binary data to the server.
- A dispatcher servlet running in a web container that recreates the Java object on the server and executes the request.

任谁 2024-09-19 22:52:31

我可能会为此感到兴奋,但我建议使用 JavaFX。我们已经成功实现了一个供大型公司内部使用的 JavaFX 应用程序。优点是该软件是在服务器端“控制”的(因此,没有人会拥有“旧”版本)。安装工作量很小(Java Web Start 为您解决了这个问题,如果不存在,它甚至会触发最小的 JRE 安装),最后但并非最不重要的一点是,JavaFX 可以在浏览器中运行,并且可以作为纯桌面应用程序运行,而无需进行更改代码。

Adobe FLEX 是另一个竞争者,但它缺乏“Web Start”位,并且在浏览器和桌面之间轻松迁移时不够灵活。

不管怎样,JavaFX 的功能并不像 FLEX 那样完整,但 1.3 版可以被认为是做好了战斗准备,您可以使用 Adob​​e Creative Suite 的免费 JavaFX 插件创建简洁的东西(如果您的应用程序包含任何图形)。

I will probably get stoned for this, but I suggest JavaFX for this. We have successfully implemented a JavaFX-application for internal use in a larger company. The advantages are that the software is "controlled" on the server side (thus, nobody will have an "old" version). Installation effort is minimal (Java Web Start fixes this for you, it will even trigger a minimal JRE-installation if none exist) and last but not least, JavaFX can be run in the browser and as a pure desktop application alike without having to change the code.

Adobe FLEX is another contender, but it lacks the "Web Start" bit and is not quite as flexible when it comes to easy migration between browser and desktop.

Anyway, JavaFX is not quite feature complete as FLEX but version 1.3 can be considered battle-ready and you can create neat stuff with the free JavaFX plugins for Adobe Creative Suite (if your app will contain any graphics, that is).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文