Java – Including jars in classpath on commandline (javac or apt)


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).

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;

public class HelloImpl {

   * @param name
   * @return Say hello to the person.
   public String sayHello(String name) {
     return "Hello, " + name + "!";

Compile errors: package javax.jws does not exist
import javax.jws.WebService;
                 ^ cannot find symbol
symbol: class 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:

Best Solution

Try the following:

java -cp jar1:jar2:jar3:dir1:. HelloWorld

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.

Related Question