Skip to content
Advertisement

Could not find or load main java class jar on AWS EC2 Linux

I need to run on Linux on AWS EC2 me jar file. I have a multi-project on Gradle. I know that there are many analogs of my problem, but I did not find anything with the multi-project.

The structure of my project is as follows

JavaScript

My build.gradle in demo.

JavaScript

When I execute the command jar, I get jar file that I run on Linux java -jar '/home/ec2-user/demo-0.0.1-SNAPSHOT-plain.jar' and it gives me an error.

Could not find or load main class com.example.DemoApplication

Advertisement

Answer

As a result, I tricky with the Gradle and Spring-boot versions. What did I do to make it work:

  1. Created a new project in start.spring.io with Java 11 and Spring Boot 2.5.8(SNAPSHOT).
  2. Moved the whole project to a new one.
  3. I also used 2 commands before gradle clean and gradle build. And in the working version I used gradlew clean build.
  4. And launched the jar file in Linux as usual.

Hope it helps someone someday 🙂

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement