It should be quite straightforward to run your application from an IDE with some maven support (Eclipse, IntellIJ). These IDE's will take care about creating the correct classpath.
If you want to do this manually, try this:
change to the directory that contains the pom.xml execute the maven command:
mvn clean install
This will compile your project and create the jar you defined in the pom.xml file. It runs the maven phases clean and every phase up to install (compile, test, etc).
Then collect all jar files you use as dependencies (required to run your project):
mvn dependency:copy-dependencies
This executes the dependency plugin which will copy all dependencies into target/dependency.
You can then run your main method using:
cd target/
java -cp TCPPing-0.0.1-SNAPSHOT.jar:dependency TCPPing
-cp defines the classpath (all locations / jar files / folders that contain classes). TCPPing is the class your run that has a main method.
Note the : is for Linux / Mac - I think windows uses a ;.
It should be quite straightforward to run your application from an IDE with some maven support (Eclipse, IntellIJ). These IDE's will take care about creating the correct classpath.
If you want to do this manually, try this:
change to the directory that contains the pom.xml execute the maven command:
mvn clean install
This will compile your project and create the jar you defined in the pom.xml file. It runs the maven phases clean and every phase up to install (compile, test, etc).
Then collect all jar files you use as dependencies (required to run your project):
mvn dependency:copy-dependencies
This executes the dependency plugin which will copy all dependencies into target/dependency.
You can then run your main method using:
cd target/
java -cp TCPPing-0.0.1-SNAPSHOT.jar:dependency TCPPing
-cp defines the classpath (all locations / jar files / folders that contain classes). TCPPing is the class your run that has a main method.
Note the : is for Linux / Mac - I think windows uses a ;.
Javac knows nothing about maven. Thus it will not utilize the maven pom.xml.
The value of maven is that it removes the manual work of building, testing and releasing a project.
This includes getting dependencies, and running javac with them added to the classpath of the javac command.
You can manually execute javac after maven downloads dependencies to ~/.m2/repository. However you'll need to tell javac where to find the jars. Thus is done via the classpath argument.
If you are trying to run the project after using mvn to compile it, you'll need to do this in the same folder where your .class files were placed. Thus should be /target/java or similar.
Videos
Backslash means the command continues to the next line (if you have a newline character). https://stackoverflow.com/a/14681059
You can simple enter mvn archetype:generate in terminal and you will be asked to enter groupId, artifactId etc. See please example.
Try these below Commands.
mvn archetype:generate -DgroupId=com.example -DartifactId=my-springboot-app -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false
mvn archetype:generate -DgroupId=com.companyname.bank -DartifactId=consumerBanking -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false