• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Compiling using a JAR file in the classpath

 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Trying to get a class to compile here, need some help. This is from SB SCJP5, Ch. 10, question 12. Given two files:

and the following sub-directory structure:

test
|--UseKit.class
|
com
|--KitJar.jar


I've compiled Kit.class and made KitJar.jar, confirmed by

jar -tf KitJar.jar
META-INF/
META-INF/MANIFEST.MF
pkg/
pkg/Kit.class


Now, here's the problem... trying to compile UseKit.java. If I'm in directory test, I thought that i would compile with

javac -cp com/KitJar.jar UseKit.java


but get the error

UseKit.java:1: '.' expected
import pkg;
^
1 error


Trying to decipher the error, it looks like the compiler can't search the current directory... so I also tried

javac -cp com/KitJar.jar:. UseKit.java


and get the same error. What am I doing wrong?
 
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your import statement seems to be wrong to me.

Are you sure "import pkg;" is correct?

Shouldn't it be

"import pkg.*" or "import pkg.Kit"; or something like that?

That seems to be the error to me.
 
richard rehl
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Absolutely right! Thank you!
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic