convert war file to exe file [closed]

2020-03-26 01:34发布

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

4条回答
ゆ 、 Hurt°
2楼-- · 2020-03-26 02:10

.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.

查看更多
smile是对你的礼貌
3楼-- · 2020-03-26 02:25

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.

查看更多
Emotional °昔
4楼-- · 2020-03-26 02:29

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.

查看更多
贼婆χ
5楼-- · 2020-03-26 02:29

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.

查看更多
登录 后发表回答