This question has been asked before but I searched through almost all of them and still can't find an answer fitting to solve my problem.
So I created my java program and when I run it in IntelliJ all is OK. In File->Project Structure I have created a new jar with 'from modules with dependencies'. I set the manifest file in my src/main/java in the manifest file my main class is defined: 'Main-Class: telematics.GetTelematicsData' and I write the jar file to my desktop. I did build->build artifact and the jar is placed on my desktop. when I run the jar file from command line with following command
java -jar filepath.jar
It throws the error:
Error: Could not find or load main class telematics.GetTelematicsData
I took the jar file and unzipped it. When I looked into the unzipped folder in the structure there is a telematics folder with a file GetTelematicsData.class (which is indeed my main class).
Some people say in SO that it might be because of some dependencies in maven in the POM file which give the error, but I have no idea how to find the incorrect ones nor how to test this.