Java:打包类文件

Java:打包类文件,java,java-package,Java,Java Package,我学习了Java软件包。不幸的是,我不明白为什么编译这些.java文件会导致编译错误 我有以下3个java文件:Node.java、InvertedFile.java和Postings.java,它们都在Mac OS X上的/Users/tracking/Desktop/implementation/mytree目录下 package mytree; import java.util.*; // Node.java public class Node { priv

我学习了Java软件包。不幸的是,我不明白为什么编译这些.java文件会导致编译错误

我有以下3个java文件:
Node.java
InvertedFile.java
Postings.java
,它们都在Mac OS X上的
/Users/tracking/Desktop/implementation/mytree
目录下

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;
    }

}
问题是java编译器不知道
节点.java
在哪里,它实际上位于
~/Desktop/implementation/mytree
中。它向我报告的编译错误没有任何帮助

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
跟踪:mytree跟踪$pwd
/用户/跟踪/桌面/实施/mytree
跟踪:mytree跟踪$javac Node.java
跟踪:mytree跟踪$javac Postings.java
Postings.java:7:找不到符号
符号:类节点
位置:mytree类。发布
私有列表同级;//内部节点。
^
Postings.java:9:找不到符号
符号:类节点
位置:mytree类。发布
公开发布(int parentID,列出兄弟姐妹)
^
2个错误

另外,我尝试使用
javac-d。java
。我总是犯同样的错误。谁能帮我解决这个问题?提前谢谢。

Java希望在名为
mytree
的目录中找到源文件。从路径
/Users/tracking/Desktop/implementation

javac mytree/*.java 

使用以下命令从/Users/tracking/Desktop/implementation编译

javac -cp . Postings.java

Node.class应该位于与包匹配的子目录中。

javac mytree/Node.java??是否可以一起编译所有包<代码>javacmytree/*.java
javac mytree/*.java 
javac -cp . Postings.java