I built my project and generated a JAR file using Gradle build framework. However, the output jar file fails to load the main methods from the main class (miner.Tracker) in this case.
As I mentioned, a run with -jar option failed.
$ java -jar Backtracker.jar
Error: Could not find or load main class miner.Tracker
I also tried to directly run the class with -cp option but it failed.
$ java -cp Backtracker.jar miner.Tracker
Error: Could not find or load main class miner.Tracker
Lastly, I uncompressed the jar file and call the class from inside. This time, it has succeeded to find and run the class with the main method.
$ mkdir classes
$ cd classes
$ classes $ tar xvf ../Backtracker.jar
x META-INF/
x META-INF/MANIFEST.MF
x CHANGELOG.md
x com/
1. ...
classes $ java miner.Tracker
2021-04-12 22:47:48.008 | Logging started
...
Here's the contents of META-INF/MANIFEST.MF file.
Manifest-Version: 1.0
Implementation-Title: BackTracker
Implementation-Version: 1.9.xx
Specification-Title: release
Specification-Version: 1.9.xx
Main-Class: miner.Tracker
And I am running it from Oracle Java 1.8.
$ java -version
java version "1.8.0_271"
Java(TM) SE Runtime Environment (build 1.8.0_271-b09)
Java HotSpot(TM) 64-Bit Server VM (build 25.271-b09, mixed mode)
Thanks for your help.
Update:
$ tar tvf Backtracker.jar |grep miner\/Tracker
-rw-r--r-- 0 0 0 2175 Apr 14 20:38 miner/TrackerUtil.class
-rw-r--r-- 0 0 0 40963 Apr 14 20:38 miner/Tracker.class