如何将 Java 桌面应用程序转换为 Web 应用程序
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14548466/
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
how to convert java desktop application into web application
提问by palatok
I have made a Java desktop application which simply stores information about the customers. Now I'm asked to make the necessary changes to make it a web application. I'm completely new to Java web development.
我制作了一个 Java 桌面应用程序,它只存储有关客户的信息。现在我被要求进行必要的更改以使其成为 Web 应用程序。我对 Java Web 开发完全陌生。
What I understand is that I will be given a server and I have to keep the program in that and only the admin will be able to run the program.
我的理解是,我将获得一个服务器,我必须将程序保留在其中,并且只有管理员才能运行该程序。
Can I just link to the application by some script so that my main program remains unchanged? My application is based on Swing and a simple file based database.
我可以通过一些脚本链接到应用程序,以便我的主程序保持不变吗?我的应用程序基于 Swing 和一个简单的基于文件的数据库。
回答by Reimeus
Have a look at Java Web Startas a means of deploying your Swing application. You should be able to avoid a re-write of your application depending on the end-user requirements.
查看Java Web Start作为部署 Swing 应用程序的一种方式。您应该能够根据最终用户的要求避免重写您的应用程序。
回答by Mihai8
You must determine what type of web application you want: servlet or applet? Also you can switch to an application type JavaFX. For starters try reading something about the basic structure of cups types of applications. For using applet see How to convert a Swing Application to an Applet?
您必须确定所需的 Web 应用程序类型:servlet 还是小程序?您也可以切换到应用程序类型 JavaFX。首先,尝试阅读有关杯子类型应用程序的基本结构的一些内容。有关使用小程序的信息,请参阅如何将 Swing 应用程序转换为小程序?
回答by Stephen C
Can i just link to the application by some script so that my main program remains unchanged ?
我可以通过一些脚本链接到应用程序,以便我的主程序保持不变吗?
The simple answer is No.
简单回答是不。
I recommend that you get some training on how to write web applications in Java. After you've done that, you will have a better idea of what needs to be done.
我建议您接受一些有关如何用 Java 编写 Web 应用程序的培训。完成后,您将更好地了解需要做什么。
Note that both Applets and JWS would involve the user installing Java on his PC in order to run your code.
请注意,Applet 和 JWS 都需要用户在其 PC 上安装 Java 以运行您的代码。
In the former case, the user must enable a Java plugin in his web browser, and that represents a significant security risk.
In the latter case, you don't has a "web application" in the normal sense. Rather you have a regular Java application that is launchedfrom the web. (Storing data on the server is a problem that you still have to solve ...)
在前一种情况下,用户必须在其 Web 浏览器中启用 Java 插件,这代表了重大的安全风险。
在后一种情况下,您没有通常意义上的“Web 应用程序”。相反,您有一个从 Web启动的常规 Java 应用程序。(在服务器上存储数据是一个你仍然需要解决的问题......)