Skip to content

How to start up spring-boot application via command line?

I have a spring-boot application which I need to start up by going to the folder directory and start up my web application via command line. I have a class called and the code inside it is as followed.

@SpringBootApplication(scanBasePackages = {""})
public class Application extends SpringBootServletInitializer {
    private static final Logger LOGGER = LoggerFactory.getLogger(Application.class.getName());
    private static final Class<Application> applicationClass = Application.class;

    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(applicationClass);

    public static void main(String[] args) {"Starting...");, args);

I set up classpath then tried to run the command “java ApplicationUtility” but I’m getting this error message “Could not find the main class: ApplicationUtility. Program will exist.


You will need to build the jar file first. Here is the syntax to run the main class from a jar file.

java -jar path/to/your/jarfile.jar fully.qualified.package.Application