Class is present in JAR, but still “Could not find or load main class”

穿精又带淫゛_ 提交于 2020-01-05 01:54:10

问题


I downloaded and installed UMD's FindBugs 3.0 in /usr/local/share/findbugs-3.0:

$ ls /usr/local/share/findbugs-3.0/
FindBugs.jar

I have a little script to run it:

$ cat ./findbugs

FINDBUGS_HOME=/usr/local/share/findbugs-3.0
java -jar $FINDBUGS_HOME/FindBugs.jar $*

Running the script results in:

$ ./findbugs 
Error: Could not find or load main class edu.umd.cs.findbugs.bluej.FindBugsExtension

Dumping the JAR:

$ jar tf /usr/local/share/findbugs-3.0/FindBugs.jar | grep "edu/umd/cs/findbugs/bluej/F"
edu/umd/cs/findbugs/bluej/FindBugsCompileListener.class
edu/umd/cs/findbugs/bluej/FindBugsExtension.class
edu/umd/cs/findbugs/bluej/FindBugsPreferences.class

It seems the class is available. I'm not sure how to proceed because java -jar ... usually works. And the FindBug docs tell me to run java -jar $FINDBUGS_HOME/findbugs.jar

What does “Could not find or load main class” mean? is good, but I think I am doing everything the question tells me to check for.

I don't have sources and don't build the JAR (I'm using a supplied JAR), so this does not seem to apply: Could not find or load main class with a Jar File. I did try running with java -cp $FINDBUGS_HOME/FindBugs.jar edu.umd.cs.findbugs.bluej.FindBugsExtension as suggested, but it results in the same error. And I did verify the dash (-) was correct per Max's answer.

I've also tried some knob turning, like removing the export CLASSPATH, removing the quotes around $FINDBUGS_HOME/FindBugs.jar and removing the $* from the command, but they have not helped.

What seems to be the trouble here? How do I make java find/load the class when running findbugs?


Possibly related: OS X 10.8.5, fully patched.

$ java -version
java version "1.8.0_05"
Java(TM) SE Runtime Environment (build 1.8.0_05-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.5-b02, mixed mode)

来源:https://stackoverflow.com/questions/27951908/class-is-present-in-jar-but-still-could-not-find-or-load-main-class

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!