I want to distribute a command-line application written in Java on Windows.
My application is distributed as a zip file, which has a lib directory entry which has the .jar files needed for invoking my main class. Currently, for Unix environments, I have a shell script which invokes the java command with a CLASSPATH created by appending all files in lib directory.
How do I write a .BAT file with similar functionality? What is the equivalent of find Unix command in Windows world?
Why would you use find? Presumably you know all the libraries your jar file needs ahead of time, so why not just list them?
Alternatively, you could always use
-Djava.ext.dirs=lib
and let it pick up everything that way.Since 6.0, Java supports wildcard classpaths.
Java command-line classpath syntax
A variation if you want the CLASSPATH setting to hold outside of the script and you didn't start the shell with /V, you can do something like this:
Useful for setting up your environment when you are just playing around on the command line.