Win a copy of Pipeline as Code this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Rob Spoor
  • Henry Wong
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh
  • Jj Roberts

A strange compile classpathing issue Im having

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As far as I can see from that output, microemulator.jar is not in your classpath.
 
Wayne Motycka
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Marshal
Posts: 26473
81
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 607
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
author and iconoclast
Posts: 24203
44
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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)]
 
Wayne Motycka
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Be reasonable. You can't destroy everything. Where would you sit? How would you read a tiny ad?
SKIP - a book about connecting industrious people with elderly land owners
https://coderanch.com/t/skip-book
reply
    Bookmark Topic Watch Topic
  • New Topic