放在同一个目录里
然后
import PackageName.SuperClass;

import PackageName.*;

解决方案 »

  1.   

    子类和超类放在不同的.java文件中是最平常不过的事情了。 如果子类与超类属于不同的包,则需要在子类的.java文件中import超类(也可以不import,但是每次用到超类的时候都要写超类完整的名字)。 CLASSPATH环境变量是用来指明类文件存放的目录或文件(一般是.jar或.zip文件),是用来帮助虚拟机或编译器等找类的。 import不是用来找类或“装载”类的,其作用仅仅是告诉编译器某些类的短名(象 Vector 是 java.util.Vector的短名)代表的完整类名(如java.util.Vector是完整类名)是什么,也就是说,import仅仅是在编译的过程有用。如果你不介意每次用到一个类的时候都写类的完整类名,完全不需要写import语句。
      

  2.   

    可以给每个文件打包:在文件头上加上一句package Xxx//xxx是你这个文件所属的文件夹名!然后和其他的一样用import 包含进来!
      

  3.   

    //SuperClass.java
    class SuperClass
    {
    ...
    }
    //ThisClass.java
    class ThisClass extends SuperClass
    {
    ...
    }
    两者在同一目录。本来方法很多,但你问了这个问题,说明你现在对她不是很了解,用这种就行了,其他的以后你自然就知道了。
    classpath是设置你的程序想使用的其他类的路径的,比如我显示用D:\A.java
    在原classpath=...后加,对:D:\既可。只是一种DOS的环境设置。///////////////////////以下是java的文档介绍的////////////////////
    The class path can be set using either the -classpath option when calling an SDK tool (the preferred method) or by setting the CLASSPATH environment variable. The -classpath option is preferred because you can set it individually for each application without affecting other applications and without other applications modifying its value. 
    C:> sdkTool -classpath path1;path2... -or- C:> set CLASSPATH=path1;path2... where: sdkTool 
    A command-line tool, such as java, javac, or javadoc. For a listing, see SDK Tools. path1;path2 
    Paths to the .jar, .zip or .class files. Each path should end with a filename or directory depending on what you are setting the class path to: 
    For a .jar or .zip file that contains .class files, the path ends with the name of the .zip or .jar file. 
    For .class files in an unnamed package, the path ends with the directory that contains the .class files. 
    For .class files in a named package, the path ends with the directory that contains the "root" package (the first package in the full package name). 
    Multiple path entries are separated by semi-colons. With the set command, it's important to omit spaces from around the equals sign (=). The default class path is the current directory. Setting the CLASSPATH variable or using the -classpath command-line option overrides that default, so if you want to include the current directory in the search path, you must include "." in the new settings. Classpath entries that are not either a directory or an archive (.zip or .jar file) are ignored.