程序包com.test.chapter06.bean不存在

teayear
前端领域优质创作者
博客专家认证
2014-04-27 10:22:38
package com.test.chapter06.bean;

public class Student {
//Student的属性
public String name="张三";
public int age=21;
//定义三个不同的构造方法
public Student(){};
//输出学生的信息
public String toString(){
String stb=new String();//
stb+="学生姓名";
stb+=name;
stb+="\n";
stb+="学生年龄";
stb+=age;
stb+="\n";
return stb;
}
}

package com.test.chapter06.main;
import com.test.chapter06.bean.*;

public class TestStudent {
public static void main(String[]args){
Student stu=new Student();
System.out.println(stu);
}
}
为什么使用MyEclipse可以编译成功,但是使用javac提示有错误呢?不能成功引用另外一个包中的类!
...全文
190 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
-江沐风- 2014-04-28
  • 打赏
  • 举报
回复
在命令行编译和myeclipse里有点不同; 参考:http://songyishan.iteye.com/blog/1178430
yufengdxw 2014-04-28
  • 打赏
  • 举报
回复
确保import的类在classpath中,或者在本次编译.java文件范围内

62,614

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧