aspose file tools*
The moose likes Beginning Java and the fly likes classpath inclusion for all jars in a folder? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "classpath inclusion for all jars in a folder?" Watch "classpath inclusion for all jars in a folder?" New topic
Author

classpath inclusion for all jars in a folder?

manuel aldana
Ranch Hand

Joined: Dec 29, 2005
Posts: 308
hi,

i remember, that with java 5 or 6 it is possible to include a whole folder with jars. something like java -classpath libFolder/*.jar.

which arguments or properties do i pass the jvm to do this?

thanks.


aldana software engineering blog & .more
Tony Docherty
Bartender

Joined: Aug 07, 2007
Posts: 2285
    
  49
You don't need the .jar extension. The '*' is expanded to all jar files in the directory so java -classpath libFolder/* should do it for you.
manuel aldana
Ranch Hand

Joined: Dec 29, 2005
Posts: 308
thanks, that worked perfectly.

really wonder, why this important feature was not included in java < 1.5.
Peter Chase
Ranch Hand

Joined: Oct 30, 2001
Posts: 1970
Well, I learnt something here. I didn't know this had changed.

It's a convenient feature, I suppose, but possibly encourages lazy configuration and could produce hard-to-diagnose configuration bugs (e.g. a left-over Jar from some old build unexpectedly gets loaded). Could be security worries, too, as it makes it easier for ne'er-do-wells to add their code to your program. I guess Sun decided that, overall, the benefits outweighed the costs, but it's certainly not a no-brainer question.

I am guessing that this is a specific convenience feature of Sun's "java[.exe]" application launcher, not part of the JVM or the Java language. So, people (like me) using their own launcher won't get this facility. I certainly don't want that feature in my code.

Can anyone confirm or disprove that this is just a Sun launcher feature?

Does anyone know if JDB has gained the same new facilities?
[ September 03, 2007: Message edited by: Peter Chase ]

Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
Peter Chase
Ranch Hand

Joined: Oct 30, 2001
Posts: 1970
In a burst of over-enthusiasm, I've discovered, the hard way, the answer to my questions above.

The wildcard facility is restricted to Sun JDKs. Importantly, for me anyway, there is no such facility on Apple Mac OS X JDK, even though it is Java 5, which has the facility in the Sun world.
Tony Docherty
Bartender

Joined: Aug 07, 2007
Posts: 2285
    
  49
In a burst of over-enthusiasm
Steady on, you'll do yourself a nasty injury if you're not careful. I suggest next time you feel this way you quickly find a sofa and a large beer and then drink until the urge passes

Joking apart I share your concerns about this "feature". The only benefit I can see is it saves typing out the full classpath. Although I suppose if your code can have plug-in modules these can be dropped into the folder and will be autoloaded on restarting without having to change the startup script which maybe another plus. Personally I agree that the pro's are outweighed by the cons. Does anyone know of a reason why this is really useful?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: classpath inclusion for all jars in a folder?