This week's book giveaway is in the OCAJP forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide 1Z0-808 and have Jeanne Boyarsky & Scott Selikoff on-line! See this thread for details.
I'm having a particularly frustrating problem that has stymied me for several days and I wanted to throw it up here to see if anybody else has any ideas on it. I am trying to refer to a class that exists in a jar file to which I'm pointing on the CLASSPATH (and I've tried it using -cp on the cmd line also) but the compiler continues to complain that it cannot find the class/path. I will first show the compiler (verbose) output here:
So, obviously the class org.microemu.app.Main isn't being found, yet here is what "jar tvf microemulator.jar" says about Main classes within it:
In the above output I see org/microemu/app/Main.class which should make this class visible to javac but it's not. For those who want to peruse my source code, here's what I'm trying to compile:
I have also tried to point to the CLASSPATH to the base directory from which the jar file is created so the path from that point has an org/microemu/app/Main.class file present with the same result. I've tried rearranging the order of the jars on the CLASSPATH with effect.
So, great Gurus, what faux pas am I perpetrating on Java syntax or usage that would cause the compiler's class resolver to dislike my class/jar?
As far as I can see, that jar file doesn't show up in the "search path for class files" in your verbose output. The other jars in your classpath do. You might investigate why that is.
Joined: Jul 13, 2009
Paul your observational skills are accurate and my screen sweeps seem to be lacking. I ran the compile again (below) and it puts the microemulator.jar into the path to be searched for sources (?) rather than the path to search for jars:
So, why does the compiler treat something I've put onto the CLASSPATH as a location to search for source, and why doesn't it find my class?
Joined: Jul 13, 2009
After posting that last one I noticed that that snapshot didn't show what I had observed, that the microemulator.jar is being enumerated by the compiler in the path for source files so I played with my command line classpath again and here is a screen snapshot that does show microemulator.jar in the path to search for sources (which is mystifying since I'm specifying it on the classpath)
is flat-out wrong; there are no circumstances under which you can pass a class name this way as an argument to a method. Since we don't know the signature of "ComponentTester", we don't know for sure, but I would imagine one of the following is correct:
After looking at his response I noted the little difference that wasn't jumping out in how to use the getTester() method. For those who are wondering, this is my feeble attempt to figure out how to use the Abbot test framework, that's where this ComponentTester class is from. As it turns out, the getTester() expects a .class extension on the passed class name. Thus, the real problem wasn't the compiler it was how the method expected the object representation to be passed.
Kudos to Ernest who showed why he's a sheriff in this town! Many thanks to all those who responded.