devlperMoose
devlperMoose

Reputation: 315

how to run a spring boot application from linux using putty

I am not able to run a spring boot application (main class) from UNIX using putty with could not find or load main class error.

All files are given 0755 executable permissions under the project folder. Tried using command: java -cp .:batch-services.jar:lib/* com.spring.integration.demo.SpringBootDemoApplication

Running command from the path: /app/batch

Folder structure in UNIX:

/app/batch/lib - this folder has all the dependency jars

/app/batch/batch-services.jar

Expected result is that the spring boot application will start successfully.

Actual result is:

Error: Could not find or load main class com.spring.integration.demo.SpringBootDemoApplication

Upvotes: 0

Views: 1444

Answers (1)

Mateusz Stefek
Mateusz Stefek

Reputation: 3846

It looks like you have encountered a common issue with how Java interacts with shell wildcards (asterisks). Java expects your classpath elements to be separated by colons, but your shell generates spaces.

The solution is to quote the argument. See this answer: Including all the jars in a directory within the Java classpath

Also, if you are using spring-boot, you can build your application into a so called fat-jar.

Upvotes: 2

Related Questions