在命令行上的classpath中包含jar(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.
这篇关于在命令行上的classpath中包含jar(javac或apt)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!