File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Compiling using a JAR file in the classpath

 
richard rehl
Ranch Hand
Posts: 36
  • 0
  • Mark post as helpful
  • send pies
  • 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?
 
Larry Olson
Ranch Hand
Posts: 142
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Absolutely right! Thank you!
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic