我有两个程序
一个在目录 /home/redhat/Documents/java1/j1
Demo1.java
当我说
我收到了以下错误信息。
我想在Demo2中访问Demo1实例,请帮忙。
Demo1.java
package j1;
public class Demo1
{
public void print()
{
System.out.println("hi");
}
}
另一个在目录 /home/redhat/Documents/java1/j 中
Demo2.java
import j1.*;
public class Demo2
{
Demo2()
{
Demo1 d=new Demo1();
}
}
当我说
javac -classpath /home/redhat/Documents/java1/j1 Demo2.java
我收到了以下错误信息。
Demo2.java:2: package j1 does not exist
import j1.*;
^
Demo2.java:7: cannot access Demo1
bad class file: /home/redhat/Documents/java1/j1/Demo1.java
file does not contain class Demo1
Please remove or make sure it appears in the correct subdirectory of the classpath.
Demo1 d=new Demo1();
^
2 errors
我想在Demo2中访问Demo1实例,请帮忙。