It is possible to generate a classpath file during a build, for instance using the maven-dependency-plugin to create a file named classpath:
mvn dependency:build-classpath -Dmdep.outputFile=classpath
How can I then use the file when invoking java from the command line?
Since JDK9 the java command supports @-file arguments where the file contents are used in place of the @-file placeholder.
Example: