在命令行的类路径中包含 jars(javac 或 apt) [英] Including jars in classpath on commandline (javac or apt)
问题描述
试图运行这个程序.我认为要设置我需要运行 apt 的所有 Web 服务.(虽然使用 javac 我有同样的问题).我认为我得到的是编译错误.(显示在底部).
trying to run this program. I think that to setup all of the web service stuff I need to run apt. (Although using javac I am having the same issue). I think what I am getting is compile errors. (Shown at bottom).
我认为我需要做的是在我的类路径中包含这个 jar:jsr181-api.jar (来源).有没有一种简单的临时方法来做到这一点(在solaris上)?我不想将它添加到我的 bash_rc 文件中(它永远存在).我也知道有一些方法可以使用清单文本文件来做到这一点,但这看起来很复杂,所以我还没有研究它.我可以做类似的事情吗:
I think what I need to do is include this jar in my class path: jsr181-api.jar (source). Is there a simple temporary way to do this (on solaris)? I don't want to add it to my bash_rc file (it is there forever). I also know that there is some way to do it using a manifest text file but that seemed complicated so I didn't look into it yet. Can I just do something like:
javac HelloImp <listOfJars>
或
ant HelloImp <listOfJars>
代码:
package server;
import javax.jws.WebService;
@WebService
public class HelloImpl {
/**
* @param name
* @return Say hello to the person.
*/
public String sayHello(String name) {
return "Hello, " + name + "!";
}
}
编译错误:
HelloImpl.java:3: package javax.jws does not exist
import javax.jws.WebService;
^
HelloImpl.java:5: cannot find symbol
symbol: class WebService
@WebService
^
2 errors
更新: 很酷,但它仍然不能正常工作.我创建了一个 新问题 以保持良好和有条理:
Update: Cool that is wrapped up but it is still not quite working. I have created a new question to keep things nice and organized:
推荐答案
尝试以下操作:
java -cp jar1:jar2:jar3:dir1:. HelloWorld
默认的类路径(除非有 CLASSPATH 环境变量)是当前目录,所以如果你重新定义它,请确保像我所做的那样将当前目录 (.) 添加到类路径中.
The default classpath (unless there is a CLASSPATH environment variable) is the current directory so if you redefine it, make sure you're adding the current directory (.) to the classpath as I have done.
这篇关于在命令行的类路径中包含 jars(javac 或 apt)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!