1

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.

Chathurika Senani
  • 716
  • 2
  • 9
  • 25

2 Answers2

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.

  1. convert war to jar in the pom.xml
<packaging>jar</packaging>
  1. extends SpringBootServletInitializer

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