放在同一个目录里
然后
import PackageName.SuperClass;
或
import PackageName.*;
然后
import PackageName.SuperClass;
或
import PackageName.*;
解决方案 »
- 烦人的需求,大家帮帮我看看呀,wed程序的检测工具
- 报错“java.lang.ClassNotFoundException”
- 父类的静态变量被继承后,子类修改静态变量,为什么父类的也跟着变了?
- 请教 栈轨迹问题
- java中JTable的遍历
- java 播放器 波形图 进度条 动态图片
- System.out.println是不是线程安全的?
- 在普通的JLabel上图片显示不出来的问题
- 给beyond_xiruo(希偌)的关于java图像连线的问题
- 各位仁兄,有人知道如何让运行于windows机上软件可以在苹果机os2上正常运行啊?是否可以在苹果机的os2上装个软件即可?不胜感谢!!!
- 为什么我在win98的的dos下运行程序老出现这个(学java的第三天)
- 刚刚学习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.