I have learned Java package. Unfortunately I don't understand why compiling these .java files causes the compile error.
I have the following 3 java files: Node.java, InvertedFile.java, and Postings.java, all of which are in the directory /Users/tracking/Desktop/implementation/mytree on Mac OS X.
package mytree; import java.util.*; // Node.java public class Node { private int label; // unique integer identifier of this tree. private Node parent; private List<Integer> leaves; // the leaf value that this tree contains. private List<Node> children; // internal nodes. public Node(int uniqueID) { this.parent = null; this.label = uniqueID; this.children = new ArrayList<Node>(); this.leaves = new ArrayList<Integer>(); } public void add_leafnode(int data) { leaves.add(data); } public void add_internalnode(Node ChildNode) { children.add(ChildNode); } // print all leaves, print all children node identifier methods. public void print_all_leaves() { Iterator iter = leaves.iterator(); while( iter.hasNext() ) { Integer element = (Integer)iter.next(); System.out.println(element); } } public List<Node> Get_children() { return children; } } package mytree; import java.util.*; // Postings.java class Postings { private int parentID; private List<Node> siblings; // internal nodes. public Postings(int parentID, List<Node> siblings) { this.parentID = parentID; this.siblings = siblings; } public void print() { System.out.println(parentID); Iterator iter = siblings.iterator(); while( iter.hasNext() ) { Integer element = (Integer)iter.next(); System.out.println(element); } } } package mytree; import java.util.*; // InvertedFile.java class InvertedFile { private HashMap IF; public InvertedFile() { IF = new HashMap(); } public void Add_Posting(int InvertedList, Postings posting) { IF.put(InvertedList, posting); } } The problem is that java compiler don't know where the Node.java, which actually is in ~/Desktop/implementation/mytree, is. The compile errors that it reports to me does not give any help.
Tracking:mytree tracking$ pwd /Users/tracking/Desktop/implementation/mytree Tracking:mytree tracking$ javac Node.java Tracking:mytree tracking$ javac Postings.java Postings.java:7: cannot find symbol symbol : class Node location: class mytree.Postings private List<Node> siblings; // internal nodes. ^ Postings.java:9: cannot find symbol symbol : class Node location: class mytree.Postings public Postings(int parentID, List<Node> siblings) ^ 2 errors Also, I try with javac -d . Postings.java. I always get the same error. Could anyone help me solve this problem? Thank you in advance.