I am writing a java program for a project. I am using Maven as a manager. I have tried two approaches:
1.
mvn clean install
mvn dependency:copy-dependencies
java -cp target/Main-1.0-SNAPSHOT.jar:dependency com.company.main.Main
The first two commands work fine, and I can see the dependencies in target/dependencies class. But when I run the program, I get the error
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/validator/routines/checkdigit/LuhnCheckDigit
So it can't find my dependency.
2.
My second approach is to use mvn exec:java
. This has worked, but the project spec says I need to provide an input file through either the command line, or STDIN. I can use -Dexec.systemin=input.txt
, but I dont know how to use mvn exec:java with STDIN. I tried < input.txt but this does not work. Should I go with trying the first method, or can I use STDIN with exec:java?