convert war file to exe file [closed]

家住魔仙堡 提交于 2019-12-01 07:54:35

问题


I have a file in .war format.
Is it possible to convert it to an .exe or .jar file?


回答1:


First of all why you need to do such thing?

As stated on wiki :

A war file is a JAR file used to distribute a collection of JavaServer Pages, servlets, Java classes, XML files, tag libraries and static Web pages (HTML and related files) that together constitute a Web application.

A war file is you application which is ready to run on server. As you said you are using tomcat you just need to put the war file in webapps folder of tomcat. And start the tomcat server. Its done. Your project will successfully run. No need to build exe [of war] for this.

If you wanna give client a setup that will look like set up and setups all things to run your app then you can use a exe maker software (like installJammer)and make your exe such that it includes tomcat with your war in webapps. Make shortcut to startup file of tomcat. So now when user clicks on shortcut tomcat will start and with it your application will also start and user can access it on browser.




回答2:


Both war and jar are ZIPs. Thus, they can be easily converted.

However, wars usually store webs, while jars contain desktop programs.
So, converting a war to a jar would not be useful because, as the war contained a web, the converted jar will also contain a web, so trying to run it (as a program) will cause an error.

If you're looking to convert a web (the war) into a desktop app, this is not the way.
Please, take a look at Prism.




回答3:


.war files are intended to be run inside a web container. So what you might want to do it to put the .war file in one, and run the web container from the task scheduler. I've done something like this before (although not with a task scheduler) using Jetty. Jetty itself is a java program, so you just start it by running java.exe -jar start.jar in the Jetty directory.




回答4:


Yes, you can covert a war into a jar file by just changing the suffix.

Both wars and jars have the same basic format (they're ZIP files), but wars usually have dependent jars and a web.xml file that describes the application.

Jars and Wars contain Java class files and need a Java engine to run. However, I suspect there are tools out there that can package a JRE, with a lightweight server (if one is needed) and the war/jar file into a single "exe" file for Windows.

I just Googled java Windows exe wrappers and found the top four results looking pretty much like what you're after.



来源:https://stackoverflow.com/questions/5591787/convert-war-file-to-exe-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!