This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
I'm preparing for the new SCJP5.0 tiger exam which is going to be released. Suppose I have my clases in multiple jar files, is it possible to set the classpath to *.jar ? When I had just one jar, and I set the classpath to *.jar when I ran javac it worked fine. But it didn't work when I used 2 jar files. Any thoughts on this ?
Suppose I have my clases in multiple jar files, is it possible to set the classpath to *.jar ?
Multiple jar files can be included in the classpath using the following command:
However, using wildcard to specify multiple jar files like the one below is not possible.
When I had just one jar, and I set the classpath to *.jar when I ran javac it worked fine. But it didn't work when I used 2 jar files.
It'd be helpful if you could show us the exact commands you ran.
For more info on setting the classpath, check out "Setting the Classpath" under General Information section.
Joyce [ April 04, 2005: Message edited by: Joyce Lee ]
Joined: Jan 17, 2005
I had just one jar file which contained a class used by Test.java This is the exact command I gave javac -classpath *.jar Test.java However, when I put one more jar file in the same folder and tried the command it did not work.
You are right. I have seen the link which talks about classpaths. There is no mention of the *.jars command. But do try the above in a windows machine and do let me know.
Joined: Jul 11, 2003
You're right, Devi. With one jar file in the current directory, the classpath can be set to *.jar (I'm using JDK 5.0 on win2000). I wasn't able to reproduce the scenario you mentioned initially because I placed two jar files in the directory. This seems like a bug to me because according to the classpath doc, it says,
Each classpath should end with a filename or directory depending on what you are setting the class path to: ... For a .jar or .zip file that contains .class files, the class path ends with the name of the .zip or .jar file.
Furthermore, it doesn't make any sense to use wildcard, i.e. *.jar, when only one jar is allowed in the directory. What do you think?
Have you tried running it using "java -classpath .;*.jar Test"? It doesn't work. It only works if the name of the jar file is specified, like this "java -classpath .;pkg.jar Test". It seems like "java" behaves correctly according to the classpath doc.
Joyce [ April 05, 2005: Message edited by: Joyce Lee ]