I've got an issue with running the bnd launcher. The actual problem came up during build using gradle, but it also doesn't work when I call the jar directly. The Launcher class really does exist in that jar and it does have a main method. Anyone know why I got this error?
$ java -cp cnf/cache/biz.aQute.launcher/biz.aQute.launcher-1.4.0.jar aQute.launcher.Launcher
Error: Could not find or load main class aQute.launcher.Launcher
When I read the content of the jar, I can see that the Launcher class is really there.
$ jar tvf cnf/cache/biz.aQute.launcher/biz.aQute.launcher-1.4.0.jar
1490 Fri Sep 26 06:49:00 CEST 2014 META-INF/MANIFEST.MF
...
1586 Fri Sep 26 06:49:00 CEST 2014 aQute/launcher/Launcher$1.class
2270 Fri Sep 26 06:49:00 CEST 2014 aQute/launcher/Launcher$2.class
794 Fri Sep 26 06:49:00 CEST 2014 aQute/launcher/Launcher$3.class
1133 Fri Sep 26 06:49:00 CEST 2014 aQute/launcher/Launcher$4.class
1100 Fri Sep 26 06:49:00 CEST 2014 aQute/launcher/Launcher$5.class
1260 Fri Sep 26 06:49:00 CEST 2014 aQute/launcher/Launcher$AllPermissionCollection.class
1149 Fri Sep 26 06:49:00 CEST 2014 aQute/launcher/Launcher$AllPolicy.class
37566 Fri Sep 26 06:49:00 CEST 2014 aQute/launcher/Launcher.class
...
I've also tried loading another random class from another random jar and that does work. Only when the main method is missing, I get a different error (Main method not found in class).
Also the rights on all these files are the same, otherwise I also couldn't run 'jar tvf'.
So, any ideas?
I found the solution. It seems that I was missing a dependency, but it was an OSGi framework. When I added the felix framework to the classpath, it did start. Apparently, the Launcher class implements an interface from the OSGi framework and it won't load the class at all when it can't find this class. This could be an improvement for the java runtime (mainly the verbose output could mention this problem).
Now the question is why bnd tries to start the launcher witout a framework, but this is something I've asked them.