0

I have several class files like such hierarchy directories:

classes
└── com
    ├── www
    │   ├── ant
    │   │   └── TAPJUnitResultFormatter.class
    │   ├── taglib
    │   │   └── IncludeTag.class
    │   ├── tomcat
    │   ├── util

How could I include them in classpath? I tried to include them one by one, but didn't work.

Thanks.

1 Answer 1

0

You might find this helpful

Quoted:

When classes are stored in a directory (folder), like /java/MyClasses/utility/myapp, then the class path entry points to the directory that contains the first element of the package name. (in this case, /java/MyClasses, since the package name is utility.myapp.)

But when classes are stored in an archive file (a .zip or .jar file) the class path entry is the path to and including the .zip or .jar file. For example, to use a class library that is in a .jar file, the command would look something like this:

% java -classpath /java/MyClasses/myclasses.jar utility.myapp.Cool

So basically, point it to the root directory that all your classes exist under. Your "MyClasses" folder is probably named "bin".

4
  • It makes sense, then how to set up the name at '<include name="*.class"/>' If I only include the top path.
    – Yang
    Apr 4, 2014 at 5:20
  • No need, you'll just have a path with only one folder element.
    – TTT
    Apr 4, 2014 at 5:21
  • I set like this <fileset dir="/home/user/tasks/myproject/classes"> </fileset>. And 'classes' is the top directory above 'com', but looks still awkward. It didn't work. It still complained couldn't resolve 'import com.www.util.*;'It must be some basic thing I forgot.
    – Yang
    Apr 4, 2014 at 5:54
  • Ha, looks better this time. I should use <pathelement location="/home/user/tasks/myproject/classes"/>. Thanks.
    – Yang
    Apr 4, 2014 at 6:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.