开发者

Converting a war file into an executable file

开发者 https://www.devze.com 2023-03-08 21:16 出处:网络
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 edit

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.


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消