I did a project based on J2EE framework. Using spring/ hibernate technologies. And used Tomcat as my servlet container. I want to create a JAR file and make my web project executable. This question is asked before but answers are ambiguous.
Asked
Active
Viewed 1.8k times
1
-
1It is impossible. Diferent platform have diferent formats for executables. – talex Sep 19 '16 at 12:24
-
I've read a couple of related questions and they all say basically the same: package your application with your choice of servlet runner (Tomcat, Jetty, ...), so I don't know why you say these answers are ambiguous? – fvu Sep 19 '16 at 12:24
-
You can create a maven project with tomcat7 plugin: http://tomcat.apache.org/maven-plugin-trunk/executable-war-jar.html – chenchuk Sep 19 '16 at 12:25
-
you could convert the project to Spring Boot application and create an executable Jar file which would be portable I believe. – Jason White Sep 19 '16 at 12:26
-
You can easily deploy a `.war` file in tomcat server. Why do you need a `.exe` file? – pahan Sep 19 '16 at 12:26
-
Can you explain how to make an exe file regarding this? – Chathurika Senani Sep 19 '16 at 12:27
-
I don't believe you can create an exe, youll create an executable JAR file – Jason White Sep 19 '16 at 12:28
-
Try [this](http://stackoverflow.com/questions/5591787/convert-war-file-to-exe-file) – pahan Sep 19 '16 at 12:29
-
okay I'll edit the question to JAR. Thanks – Chathurika Senani Sep 19 '16 at 12:30
-
Once you have a JAR, you could use Launch4J to create a Windows Executable. – Jun 12 '20 at 08:26
2 Answers
1
Have a look at Spring Boot, this will help you create a jar that can be started with
java -jar <your-jar-file>
It would not need to get deployed into a servlet container, instead it will run with an embedded tomcat. You'd need to install a java runtime wherever you want to run it, though.
See this link for more information.

Daniel Hiller
- 3,415
- 3
- 23
- 33
1
To convert war file to jar in the spring boot, you need to do 3 steps.
- convert war to jar in the pom.xml
<packaging>jar</packaging>
extends SpringBootServletInitializer
override configure
public class Your_Application_Name extends SpringBootServletInitializer{
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder springApplicationBuilder){
return springApplicationBuilder.sources(Your_Application_Name.class);
}
public static void main(String[] args) {
SpringApplication.run(Your_Application_Name.class, args);
}

Rahul Jaiman
- 41
- 1
- 10