将war文件转换为可执行文件

发布于 2024-11-10 08:03:49 字数 196 浏览 2 评论 0原文

我的公司开发了一个Web应用程序(J2EE环境/Tomcat服务器)并希望将其作为产品出售。客户可以使用该产品作为基本版或高级版。在高级版中,客户有一些额外的功能(可能是一些额外的链接)。这种区别是根据序列号进行的。

当讨论上述事情时,我只是一个听众。

上述问题可以实现吗?我们如何将war文件转换为exe文件并嵌入逻辑来区分高级版本或基本版本。

My company has developed a web application (J2EE environment/Tomcat server) and wants to sell it as a product. Customers can avail this product as basic edition or premium edition. In the premium edition the customers have some extra functionalities (may be some extra links). This distinction is made based on the serial key.

I was just a listener when the above thing was discussed.

Is doing the above problem possible? How do we convert a war file into an exe file and embed logic to distinguish premium or basic version.

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

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

发布评论

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

评论(2

笑红尘 2024-11-17 08:03:49

我们如何将war文件转换为exe文件并嵌入逻辑来区分高级版本或基本版本。

这是两个不同的要求,彼此无关。

如果您有一个 Web 应用程序,您可以使用网页输入序列密钥(例如 Jira 所做的),或者您可以让密钥(或密钥文件的文件名)写入 Context.xml 中,并让servlet 读取该上下文参数。根据密钥,应用程序可以允许或不允许某些功能。

至于转换为可执行文件,“可执行文件”一词有多种解释。我认为“war”文件足够可执行 - 将其转储到 tomcat 中并运行。

如果您希望它独立,您可以提供一个预部署应用程序的 tomcat 发行版(同样,像 Jira 那样),或者使用 Jetty 嵌入式容器。尽管这可能不适合繁重的工作负载。

您甚至可以尝试使用 gjc(Gnu Java 编译器)将 jetty + 您的 Web 应用程序转换为本机 exe,尽管我怀疑它是否能像正常部署的版本一样工作。

我建议您通过上下文参数注入密钥,或者创建一个可以输入密钥的管理页面。

How do we convert a war file into an exe file and embed logic to distinguish premium or basic version.

These are 2 distinct requirements which have nothing to do with each other.

If you have a web application you can either enter the serial key using a web page (like Jira does for instance), or you could perhaps let the key (or the filename of the keyfile) be written in Context.xml, and let a servlet read that context parameter. Based on the key the application could then allow or not allow some functionality.

As for converting to an executable, there are multiple interpretations to the word executable. I for one think "war" file is executable enough - dump it in a tomcat and it runs.

If you want it standalone you could provide a tomcat distribution with your app predeployed (again, like Jira does), or use a Jetty embedded container. Although that may not be appropriate for heavy workloads.

You could even try to convert jetty + your web app to a native exe using gjc (Gnu Java Compiler) though I doubt it will work as well as the normally deployed version.

I'd advise you to either inject the key via context parameters, or create an admin page n which you can enter the key.

末蓝 2024-11-17 08:03:49

WAR 是一个网络应用程序存档。它应该在带有 servlet 容器的 Web 服务器上执行。可执行 JAR 需要一个带有 main() 方法的类,但 Web 应用程序通常没有任何方法,因为这是 servlet 容器的责任,而不是 Web 应用程序的责任。通常,WAR 将按原样分发,服务器管理员有责任将其部署到 servlet 容器。如果需要,您可以包含一些文档来描述如何对各种容器执行此操作。

如果出于某种不明显的原因,您确实打算将 Web 应用程序作为桌面应用程序出售,那么您最好的选择实际上是包含一个可嵌入的 servlet 容器(如 Jetty),并附带一个带有 main() 方法的类它创建嵌入式 servlet 容器的实例,将 WAR 文件部署到其中并运行 servlet 容器。这又可以封装在可执行 JAR 中。

或者,您也可以将其托管在互联网上的某个位置并提供特定的登录信息。

A WAR is a web application archive. It's supposed to be executed on a webserver with a servlet container. An executabele JAR requires a class with a main() method, but a web application normally doesn't have any since that's the responsibility of the servlet container, not the web application. Normally, a WAR is to be distributed as-is, it's the serveradmin's responsibility to deploy it to a servlet container. You can if necessary include some documentation which describes how to do it for various containers.

If you really intend to sell a web application as a desktop application for some unobvious reason, then your best bet is really to include an embeddable servlet container like Jetty and ship a class with a main() method along it which creates an instance of the embedded servlet container, deploys the WAR file to it and runs the servlet container. This can in turn be wrapped in an executabele JAR.

Alternatively, you can also host it somewhere on the internet and provide a specific login.

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