Is there a way to include all the jar files within a directory in the classpath?
I\'m trying java -classpath lib/*.jar:. my.package.Program
and it is no
For Java 13 on macOS Mojave…
If all your .jar
files are in the same folder, use cd to make that your current working directory. Verify with pwd.
For the -classpath
you must first list the JAR file for your app. Using a colon character :
as a delimiter, append an asterisk *
to get all other JAR files within the same folder. Lastly, pass the full package name of the class with your main method.
For example, for an app in a JAR file named my_app.jar
with a main
method in a class named App
in a package named com.example
, alongside some needed jars in the same folder:
java -classpath my_app.jar:* com.example.App