I am new to java and facing same old issue while executing the Class/Jar file, i.e. getting error which says "Could not find or load main class com.finance.LoanProcessor", where com.finance.LoanProcessor is my fully qualified class name. I have created many other sample projects, and I can execute both class/jar file in them. Only this project is causing the issue.
Here is what I understand from Java tutorials and StackOverflow solutions for this issue:
- While executing the class file directly using 'Java' command, I need to use this syntax: java com.finance.LoanProcessor
Note: I should not use '.class' suffix. In command prompt, I should be in the parent folder which has the 'com' folder, so that the java command can navigate inside the com/finance directory and execute the LoanProcessor class.
- While executing the jar file directly using the 'Java' command, I need to use this syntax: java -jar LoanOnboardingSystem-1.0-SNAPSHOT.jar
Note: I should be in the same directory where this jar file is located. Also, the jar should have the META-INF/MANIFEST.MF file, which should have the Main-Class: com.finance.LoanProcessor attribute defined.
I have kept all above notes in mind and tried executing my main class and jar both, but both are failing. While other sample projects are getting executed in same fashion on my same laptop, only this project is giving error. I have asked a few java experts in my office, but they are not able to figure out issue too.
Hence, I have uploaded the whole project on following git repository now: LoanOnboardingProject
Could the community kindly help to check the project and suggest what I am missing?
Few other things which I have done:
I am using IntelliJ IDE. I have built jar with IDE's out of box options, and it gives same error. [This jar is under the 'out' folder in above repository.]
I have created above project as Maven project. I used 'mvn package' command to build the jar, but it gives the same error. [This jar is under the 'target' folder in above repository.]
When I run the program within IntelliJ itself, it works just fine. No issues with that.
Thanks a lot in advance. Any help is much appreciated.