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 package with import statement

 
Linda Pan
Ranch Hand
Posts: 96
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've been trying to get this working .... I have 2 classes where one class uses an import statement.

My file structure is c:\Sierra\java where both the Goo and Sludge java files are located. I can compile Sludge using c:\Sierra\java> javac -d c:\Sierra\classes Sludge.java and class Sludge is correctly created in the cert folder. When I try to do the same with Goo, I get compile errors: "package cert does not exist" and "cannot resolve symbol" when it attempts to create an instance of Sludge.
I am using 1.4.1 compiler. What am I doing wrong? I was trying to keep my class vs java files in separate as recommended in previous posts.
[ March 28, 2003: Message edited by: Linda Pan ]
 
Jessica Sant
Sheriff
Posts: 4313
Android IntelliJ IDE Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you can't have two classes in different packages be defined in the same file.
Try breaking it up to two files -- and all should be fine.
 
Linda Pan
Ranch Hand
Posts: 96
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I got it working ... it appears as long as I have Sludge in the cert subdirectory, and Goo in the book subdirectory, I can compile both files using c:\Sierra\java> javac cert/Sludge.java book/Goo.java. I can run java book/Goo and get my output.
 
Linda Pan
Ranch Hand
Posts: 96
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was also working with source files in the c:\Java path. When compiling I would get the class not found compile error. Resolved my problem by setting the classpath in autoexec.bat file.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic