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 Application.java and the code inside it is as followed.
@SpringBootApplication(scanBasePackages = {"com.ubs.tas.topcat.dashboard"}) public class Application extends SpringBootServletInitializer { private static final Logger LOGGER = LoggerFactory.getLogger(Application.class.getName()); private static final Class<Application> applicationClass = Application.class; @Override protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { return application.sources(applicationClass); } public static void main(String[] args) { LOGGER.info("Starting..."); SpringApplication.run(Application.class, 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.
“
Advertisement
Answer
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