aspose file tools*
The moose likes Beginning Java and the fly likes A strange compile classpathing issue Im having Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of JavaScript Promises Essentials this week in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "A strange compile classpathing issue Im having" Watch "A strange compile classpathing issue Im having" New topic
Author

A strange compile classpathing issue Im having

Wayne Motycka
Greenhorn

Joined: Jul 13, 2009
Posts: 5
Great Gurus of Java,

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?

Many thanks in advance!

Wayne
Joanne Neal
Rancher

Joined: Aug 05, 2005
Posts: 3734
    
  16
As far as I can see from that output, microemulator.jar is not in your classpath.


Joanne
Wayne Motycka
Greenhorn

Joined: Jul 13, 2009
Posts: 5
Thanks Joanne,

The jar I am including in the javac compile step does contain the Main.class, here's what I get doing a rip apart of that class using jar:

So, my question remains the same, anybody have any ideas?
Wayne
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18878
    
    8

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.
Wayne Motycka
Greenhorn

Joined: Jul 13, 2009
Posts: 5
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?

Thanks
Wayne
Wayne Motycka
Greenhorn

Joined: Jul 13, 2009
Posts: 5
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)


Thanks to all!
Wayne
Saifuddin Merchant
Ranch Hand

Joined: Feb 08, 2009
Posts: 606

Looks like you got Rid of one error --> import org.microemu.app.Main
Also org.microemu is correctly in the class path in the screens below.

What exactly is this statement ComponentTester ctester = ComponentTester.getTester(org.microemu.app.Main); supposed to do? Could you just tell us the Signature of this method?


Cheers - Sam.
Twisters - The new age Java Quiz || My Blog
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

To add a bit of strength to Sam's question, the syntax

ComponentTester ctester = ComponentTester.getTester(org.microemu.app.Main);

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:

ComponentTester ctester = ComponentTester.getTester(org.microemu.app.Main.class);

or

ComponentTester ctester = ComponentTester.getTester("org.microemu.app.Main");


Note that in the dribble output, you can see that the "Main" class is actually being loaded:

[loading /home/wmotycka/microemulator-2.0.3/microemulator.jar(org/microemu/app/Main.class)]


[Jess in Action][AskingGoodQuestions]
Wayne Motycka
Greenhorn

Joined: Jul 13, 2009
Posts: 5
Ernest hit it on the head and solved my problem.

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.
Wayne
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: A strange compile classpathing issue Im having