我先在c:\wjj里建立一个 prjj目录
我在c:\wjj 目录中 有pwjj.java的文件 里面://?? c:\wjj\prjj
package prjj;
public class pwjj {
int a,b;
pwjj(int x,int y)
{
a=x;b=y;
}
public void setab(int x,int y)
{ a=x;b=y;}
public void showab()
{
System.out.println("a="+a);
System.out.println("b="+b);
}
}
编译后 生成 pwjj.class//?? cd c:\wjj\prjj javac pwjj.java cd .. java prjj.pwjj 然后 我又写了个 test.java 内容是://c:\wjj
import prjj.*;
public class test
{
public static void main(String[] args)
{ pwjj pa=new pwjj(10,20);
pa.showab();
pa.setab(100,200);
pa.showab();
}
}
结果编译后出现错误: 提示://classpath=.;
test.java:5: cannot access pwjj
bad class file: .\pwjj.class
class file contains wrong class: prjj.pwjj
Please remove or make sure it appears in the correct subdirectory of the classpath
我在c:\wjj 目录中 有pwjj.java的文件 里面://?? c:\wjj\prjj
package prjj;
public class pwjj {
int a,b;
pwjj(int x,int y)
{
a=x;b=y;
}
public void setab(int x,int y)
{ a=x;b=y;}
public void showab()
{
System.out.println("a="+a);
System.out.println("b="+b);
}
}
编译后 生成 pwjj.class//?? cd c:\wjj\prjj javac pwjj.java cd .. java prjj.pwjj 然后 我又写了个 test.java 内容是://c:\wjj
import prjj.*;
public class test
{
public static void main(String[] args)
{ pwjj pa=new pwjj(10,20);
pa.showab();
pa.setab(100,200);
pa.showab();
}
}
结果编译后出现错误: 提示://classpath=.;
test.java:5: cannot access pwjj
bad class file: .\pwjj.class
class file contains wrong class: prjj.pwjj
Please remove or make sure it appears in the correct subdirectory of the classpath
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货