3

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)
Community
  • 1
  • 1
jww
  • 97,681
  • 90
  • 411
  • 885
  • 1
    Unrelated, but `CLASSPATH` is useless when using `-jar`. Did you try without the quotes, since they're useless in this example? Did you paste anything into an editor for this? Does it work *without* the shell script? – Dave Newton Jan 14 '15 at 20:39
  • Why do you refer to the jar with 'FindBugs.jar' while according to the cited documentation it is called 'findbugs.jar'? Did you rename it? – Rudi Angela Jan 14 '15 at 20:39
  • What happens if you use a `jar`-less `java` command, simply specifying the `-cp`? – Sotirios Delimanolis Jan 14 '15 at 20:39
  • @ Dave - I did not know `CLASSPATH` was useless (my primary languages are C and C++). But I tried with and without it (just in case). I think using `CLASSPATH` is an artifact from college. – jww Jan 14 '15 at 20:43
  • @Rudi - `FindBugs.jar` is what was served from the SourceForge download. I did not rename it. If the 2.0.x package is downloaded, then the names are as cited in the docs. It seemed reasonable to swap in the new name :) – jww Jan 14 '15 at 20:44
  • 2
    It looks like you got a FindBugs *plugin* for BlueJ... are you using the BlueJ IDE? – Elliott Frisch Jan 14 '15 at 20:48
  • 1
    Why not run it using the script they supply?! In the `bin` directory? And Elliott is right, I don't think you're doing what you think you are. – Dave Newton Jan 14 '15 at 20:48
  • @Elliot - the [FindBugs download page](http://findbugs.sourceforge.net/downloads.html) advertises it as *"FindBugs tool (standard version with command line, ant, and Swing interfaces)"*. Maybe they crossed some wires (or maybe my wires are crossed). – jww Jan 14 '15 at 20:50
  • 1
    I downloaded and untarred the tar.gz download to "/usr/share"; `cd /usr/share && tar xzvvf ~efrisch/Downloads/findbugs-3.0.0.tar.gz` then `/usr/share/findbugs-3.0.0/bin/findbugs` started it. What did you download? – Elliott Frisch Jan 14 '15 at 20:54
  • @Elliott - so here's some more backstory... The first download got me a FindBugs 2.x download (not the 3.0 download). It did not run properly (I could not create a new project). So I tried the next 3.0 download on the SourceForge page, which ended up being just the `FindBugs.jar` file. I wish they would move away from SourceForge. Its full of confusing gimmicks. – jww Jan 14 '15 at 21:32
  • I also downloaded v3 from the link you provided with zero difficulty. There are links to the tgz and zip versions, both the automatic and direct links worked for me. Unzipped, get the bin dir, everything worked with no issues. Download the correct artifact and start over. – Dave Newton Jan 14 '15 at 21:37
  • Elliott & Dave - I think the solution here was to download another copy starting from the FindBugs page (that makes 4 tries - don't ask how I managed to munge it 3 other times). But I was able to get it to work. Can one of you answer so I can award the points? – jww Jan 14 '15 at 22:07
  • Midwest, actually. I knew of some west coast stores around at the same time, but I didn't know much about the east coast until I moved out here. – Dave Newton Jan 14 '15 at 22:11
  • 1
    Thanks for everyone's help. I'm casting a close vote as "unable to reproduce" since fetching a different JAR solved it (but the original problem still exists). I'm going to leave it on the site in case it helps others who get the wrong FindBugs package from SourceForge. – jww Jan 14 '15 at 22:36
  • @jww I think everyone got their TRS-80(s) at Radio Shack. I know my family got a [Model III](http://en.wikipedia.org/wiki/TRS-80#Model_III) there. – Elliott Frisch Jan 14 '15 at 22:49

0 Answers0