Meaningless Drivel is fun!*
The moose likes Beginning Java and the fly likes Another Package Question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Another Package Question" Watch "Another Package Question" New topic
Author

Another Package Question

Rob Keefer
Greenhorn

Joined: Feb 18, 2002
Posts: 26
Hi,
I have an interface defined in one package that I am trying to use in another package. I get a compile error. Here is everything I know ...
In Directory /pomiet/talk
Speak.java Speak.class
Speak.java:
package pomiet.talk;
public interface Speak
{
void speak();
}
In Directory /pomiet/mammals:
Animals.java
Animals.java:
package pomiet.mammals;
import pomiet.talk.*;
abstract class Animal implements Speak
{
}
class dog extends Animal
{
public void speak()
{
System.out.println("WOOF!");
}
}
class cat extends Animal
{
public void speak()
{
System.out.println("meow");
}
}
class cow extends Animal
{
public void speak()
{
System.out.println("MOOOOO!");
}
}
public class Animals
{
public static void main(String[] args)
{
Animal b = new cow();
Animal c = new cat();
Animal d = new dog();
b.speak();
c.speak();
d.speak();
}
}

When I compile I get this:
/pomiet>javac talk/Speak.java
/pomiet>javac mammals/animals.java
mammals/animals.java:3: package pomiet.talk does not exist
import pomiet.talk.*;
^
Any suggestions?
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023

/pomiet>javac mammals/animals.java

You've got to do this from the parent directory of pomiet.


[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
And of course, Speak.class must be inside the directory talk which must be a subdirectory of pomiet.
Good Luck.
Rob Keefer
Greenhorn

Joined: Feb 18, 2002
Posts: 26
It works, thanks...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Another Package Question
 
Similar Threads
Classpaths with packages
Reg. casting from Khalid Mughal
why this code gives compiler error.
Help me fix this,so I can compile(generics doubt)
Generics and ? symbol