I have seen several very similar questions on stackoverflow, but haven't come across anything that exactly matches my problem. I have a folder with several .java files, and another folder with two .jar files. I need to include both the jar files while using javac so that the entire project gets compiled at one go:
$: javac -classpath .:~/myjardir/*.jar ~/myprojectdir/*.java
But if I do this, only the first jar is recognized, and everything that depends on the second jar throws an error. Surprisingly, if I compile each program separately,
$: javac -classpath .:~/myjardir/oneofthejars.jar ~/myprojectdir/file1.java
then everything works fine. I have also compiled the project separately in Eclipse just to test the code and the jars. It is only when I try to use both the jars with -classpath
in command line that I get the errors. Wildcard entries are supposed to work in JDK6, so I am at a loss here.
see the SO answer here but here's the relevant paragraph from the Java documentation:
Class path entries can contain the basename wildcard character *, which is considered equivalent to specifying a list of all the files in the directory with the extension .jar or .JAR. For example, the class path entry foo/** specifies all JAR files in the directory named foo. A classpath entry consisting simply of * expands to a list of all the jar files in the current directory.