File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Wildcard on Classpath Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Wildcard on Classpath" Watch "Wildcard on Classpath" New topic

Wildcard on Classpath

Drew Lane
Ranch Hand

Joined: May 13, 2001
Posts: 296
I thought I could use the wildcard character on the classpath to include a bunch of jars in a single directory but it's not working.
java -cp C:\dir\lib\*.jar myapp
Something wrong with my syntax?
Marilyn de Queiroz

Joined: Jul 22, 2000
Posts: 9059
Is there any solution to specify the classpath using wildcards?
No there's not. There is a Bug Report to fix this, I'm not sure when Sun will get round to fixing it.
In the meantime, you can do 3 things
- write your Java bootstrap program which reads in the list of Jar files recursivley and passes then as an argument to Runtime.getRuntime().exec("java...") etc.
- use a unix script to call java for you,this time using shell script to pick all the Jar files up from the relevant directory (for *.jar in dir $classpath = $classpath:jar ) etc
- extract all the jars to one place, then rezip them up and put that on your class path.
[ March 27, 2004: Message edited by: Marilyn de Queiroz ]

"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
I agree. Here's the link:
subject: Wildcard on Classpath
It's not a secret anymore!