Results 1 to 4 of 4
Thread: [SOLVED] Compiling Package Class
- 11-06-2008, 07:27 PM #1
Member
- Join Date
- Oct 2008
- Posts
- 45
- Rep Power
- 0
[SOLVED] Compiling Package Class
Why can I not compile a single class that uses another class of the same package? I thought that all classes of a package were automatically imported.
I have a package foo. The directory is named foo. I have two classes: Foobar and Footwo. Footwo uses Foobar. If I'm in the directory foo and do javac Footwo.java, I get errors that it cannot find symbol Foobar. It works if I do javac *.java.
- 11-06-2008, 09:21 PM #2
You need to set the classpath for the compiler so it can find the class. The classpath + the package path is the location of the class file. You have the classpath pointing to the location of the class file instead of to the begining of the package path which would be up one level to where the foo directory is.
- 11-07-2008, 04:43 AM #3
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
How did you refer those three package in FooTwo class? Can you show that? Did you try what Norm says?
- 11-14-2008, 11:19 PM #4
Member
- Join Date
- Oct 2008
- Posts
- 45
- Rep Power
- 0
Similar Threads
-
Compiling a single class
By ROSOBORONEXPORTCORP in forum New To JavaReplies: 2Last Post: 01-28-2008, 12:27 PM -
Compiling a class in a package from cmd
By Java Tip in forum Java TipReplies: 0Last Post: 12-17-2007, 10:27 AM -
Importing / compiling and running with .jar package
By splinter64uk in forum New To JavaReplies: 1Last Post: 12-05-2007, 02:47 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks