Topic: 关于类的连编大问题!望高手指引迷津!

  Print this page

1.关于类的连编大问题!望高手指引迷津! Copy to clipboard
Posted by: rainv
Posted on: 2005-12-28 14:03

我在无意中使用了cmd下的javac命令编译两个类.在一个包里.
public class test1{
public static void main(String[]args){
test2 t2=new test2();
System.out.println(t2);
}
}

public class test2{
test1 t1=new test1();
public String toString(){
return "test2";
}
}
test1类引用test2类,test2类引用test1类.
一直用着JCreator工具来编译test1,都行,它会把test2连编.
在命令行下javac编译test1不行,说找不到test2.
用javac -classpath [类目录] test1.java 可以,但是,我的问题是.
当我编译其他类时在环境变量设置的其他类找不到了.如servlet包的类.
头大了.为什么javac会找不到同包下的类呢.

2.Re:关于类的连编大问题!望高手指引迷津! [Re: rainv] Copy to clipboard
Posted by: bluecrystal
Posted on: 2005-12-28 17:12

servlet包不在你自定义的包路径下,当然找不到
要在javac -classpath中指定

3.Re:关于类的连编大问题!望高手指引迷津! [Re: rainv] Copy to clipboard
Posted by: rainv
Posted on: 2005-12-28 21:57

那怎么同时引用两个包呀
这样么?
javac -classpath d:\test;${servlet.jar的路径}
斑竹~

4.Re:关于类的连编大问题!望高手指引迷津! [Re: rainv] Copy to clipboard
Posted by: why
Posted on: 2005-12-28 22:23

Why don't you try it instead of asking? Question

javac -classpath d:\test;X:\YourServletJarFolder\servlet.jar

Hopefully there's no spaces in the folder name. Otherwise you would have to put the folder list in quotes.


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923