I've got a project I've made with Maven. I compile a JAR, with "mvn package", and now I want to run it, preferably without setting some insane classpath, as it depends on Spring and half the internet or something. Is there any way I can run it easily? Something like "mvn run" would be great, or an option to throw in all dependencies into the jar so I can do "java -jar" would also be splendid.
How do you deal with this, and what do you recommend doing? Because exporting a CLASSPATH based on ~/.m2 would probably just be hurtful ;-)
Setting CLASSPATH
and calling java -jar myjar.jar
wouldn't work anyway. Because the java -jar
command ignores the CLASSPATH
environment variable as well as the -cp
flag.
In this case you had to add the classpath entries to the jar's MANIFEST at the Class-Path
key, like:
Class-Path: jar1-name jar2-name directory-name/jar3-name
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With