我在用jdk运行时出现这样的错误是为什么呀?到底哪里错了?请各位帮帮忙谢谢~
e:\java code>javac TestMyDate.java
javac:找不到文件:TestMyDate.java
用法:javac<options><source files>
-help 用于列出可能的选项
e:\java code>javac TestMyDate.java
javac:找不到文件:TestMyDate.java
用法:javac<options><source files>
-help 用于列出可能的选项
楼主【yangchunhuo】截止到2008-07-02 14:57:30的历史汇总数据(不包括此帖):
发帖的总数量:3 发帖的总分数:60
结贴的总数量:0 结贴的总分数:0
无满意结贴数:0 无满意结贴分:0
未结的帖子数:3 未结的总分数:60
结贴的百分比:0.00 % 结分的百分比:0.00 %
无满意结贴率:---------------------无满意结分率:---------------------
如何结贴请参考这里:http://topic.csdn.net/u/20080501/09/ef7ba1b3-6466-49f6-9d92-36fe6d471dd1.html
.;D:\Program Files\JDK\lib\dt.jar;D:\Program Files\JDK\lib\tools.jar
主要是前面的.;两个字符
如果是这样,运行的时候就要把同包的类引进来
试试javac -classpath .. TestMyDate.java
private int day; //日
private int month; //月
private int year; //年
public MyDate(int day,int month,int year){
this.day = day;
this.month = month;
this.year = year;
} public MyDate(MyDate date) {
this.day = date.day;
this.month = date.month;
this.year = date.year;
} public int getDay() {
return day;
} public void setDay(int day) {
this.day = day;
} public MyDate addDays(int more_days) {
MyDate new_date = new MyDate(this);
new_date.day = new_date.day + more_days;
return new_date;
} public void print() {
System.out.println("MyDate: " + day + "-" + month + "-" + year);
}
} public class TestMyDate {
public static void main(String[] args) {
MyDate my_birth = new MyDate(22, 7, 1964); //通过第一个构造函数new了一个叫my_birth的对象,并在参数里面赋值 MyDate the_next_week = my_birth.addDays(7); //这个对象调用了addDays(int more_days)的方法,赋值给the_next_week的变量
the_next_week.print(); //调用print()方法
}
}
public class TestMyDate
{
public static void main(String[] args)
{
MyDate my_birth = new MyDate(22, 7, 1964); //通过第一个构造函数new了一个叫my_birth的对象,
// 并在参数里面赋值 MyDate the_next_week = my_birth.addDays(7);//这个对象调用了addDays(intmore_days
// )的方法,赋值给the_next_week的变量
the_next_week.print();// 调用print()方法
}
}
public class TestMyDate {
public static void main(String[] args) {
MyDate my_birth = new MyDate(22, 7, 1964); //通过第一个构造函数new了一个叫my_birth的对象,并在参数里面赋值 MyDate the_next_week = my_birth.addDays(7); //这个对象调用了addDays(int more_days)的方法,赋值给the_next_week的变量
the_next_week.print(); //调用print()方法
}
} 你这段代码里的括号,分号等不是半角的
private int day; //日
private int month; //月
private int year; //年
public MyDate(int day,int month,int year){
this.day=day;
this.month=month;
this.year=year;
} public MyDate(MyDate date) {
this.day=date.day;
this.month=date.month;
this.year=date.year;
} public int getDay() {
return day;
} public void setDay(int day) {
this.day=day;
} public MyDate addDays(int more_days) {
MyDate new_date=new MyDate(this);
new_date.day=new_date.day + more_days;
return new_date;
} public void print() {
System.out.println("MyDate: "+day+"-"+ month+"-" + year);
}
} public class TestMyDate {
public static void main(String[] args) {
MyDate my_birth=new MyDate(22,7,1964); //通过第一个构造函数new了一个叫my_birth的对象,并在参数里面赋值 MyDate the_next_week=my_birth.addDays(7); //这个对象调用了addDays(int more_days)的方法,赋值给the_next_week的变量
the_next_week.print(); //调用print()方法
}
}
{
private int day; // 日 private int month; // 月 private int year; // 年 public MyDate(int day, int month, int year)
{
this.day = day;
this.month = month;
this.year = year;
} public MyDate(MyDate date)
{
this.day = date.day;
this.month = date.month;
this.year = date.year;
} public int getDay()
{
return day;
} public void setDay(int day)
{
this.day = day;
} public MyDate addDays(int more_days)
{
MyDate new_date = new MyDate(this);
new_date.day = new_date.day + more_days;
return new_date;
} public void print()
{
System.out.println("MyDate: " + day + "-" + month + "-" + year);
}
public static void main(String[] args)
{
MyDate my_birth = new MyDate(22, 7, 1964); //通过第一个构造函数new了一个叫my_birth的对象,
// 并在参数里面赋值 MyDate the_next_week = my_birth.addDays(7); // 这个对象调用了addDays(int
// more_days
// )的方法,赋值给the_next_week的变量
the_next_week.print(); // 调用print()方法
}
}
能跑的话就是你Classpath配置不对
应该是正解了,好好确认下,别偷懒!!
在“e:\java code>”下输入“dir Test*.java”确认下有没