一个狗血的问题,气死我也

习惯了IED,突然要用到javac手动编译代码,却不会了,搞了一半天,才发现这个问题真狗血。

比如有两个类 Student.java Teacher.java

 

package student;
import java.util.List;

import teacher.Teacher;


public class Student {
private String name;
private List<Teacher> teachers;
/**
* @return the name
*/
public String getName() {
return name;
}
/**
* @param name the name to set
*/
public void setName(String name) {
this.name = name;
}
/**
* @return the teachers
*/
public List<Teacher> getTeachers() {
return teachers;
}
/**
* @param teachers the teachers to set
*/
public void setTeachers(List<Teacher> teachers) {
this.teachers = teachers;
}
}

package teacher;
import java.util.List;

import student.Student;


public class Teacher {
private String name;
private List<Student> students;
/**
* @return the name
*/
public String getName() {
return name;
}
/**
* @param name the name to set
*/
public void setName(String name) {
this.name = name;
}
/**
* @return the students
*/
public List<Student> getStudents() {
return students;
}
/**
* @param students the students to set
*/
public void setStudents(List<Student> students) {
this.students = students;
}
}

 编译Student.java的时候,-classpath -sourcepath参数各种可能的值都试过了,就是提示找不到Teacher所在的位置

错误用法:javac student\Student.java

折腾了一下午,看了oracle官方文档,也没有找到答案,最后灵机一散,是不是要同时编译啊,于是

正确用法:javac student\Student.java teacher\Teacher.java

通过了,根本就不需要 classpath sourcepath参数,倒霉的一下午。

 

 

posted on 2013-07-01 20:42  wilhard  阅读(222)  评论(0)    收藏  举报