包里的文件该如何编译?

xmzw 2005-01-13 11:29:03
新手入门,大家莫笑

//test.java
package mytest;

public class test{
public test(){
System.out.println("hello");
}
}

.
.
.

//test1.java
package mytest;

public class test1{
public static void main(String[] args){
test t=new test();
...
}
}

编译时进入到mytest目录,javac test.java成功,javac test1.java时出现以下错误:
test1.java:5: cannot find symbol
symbol : class test
location: class mytest.test1
test t=new test();
^
test1.java:5: cannot find symbol
symbol : class test
location: class mytest.test1
test t=new test();
^
2 errors



请问该如何编译?
...全文
117 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
vgvg 2005-01-13
  • 打赏
  • 举报
回复
在mytest的上一级目录
javac -d . test1.java
iforem 2005-01-13
  • 打赏
  • 举报
回复
假设你的两个源程序在c:\目录下

编译:

javac -d . test.java
javac -d . test1.java


运行:
java mytest.test1

iforem 2005-01-13
  • 打赏
  • 举报
回复
javac -d . test1.java

62,615

社区成员

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

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