This project demonstrates a simple Java Command Line Interface (CLI) application built with Maven and using Picocli for command-line parsing. It includes subcommands (hello
and goodbye
) to print greetings and farewells, depending on user input. The project also leverages Maven Shade Plugin to package the application into a runnable JAR file.
To work with this project, you need to have the following installed:
- Java Development Kit (JDK) 17 or later
- Maven
- IntelliJ IDEA (optional, but recommended for development)
To build the project and create the executable JAR file, follow these steps:
-
Clone the repository:
git clone <repository-url> cd java-intellij-idea-and-maven
-
Use Maven to compile and package the project: mvn clean package
This command will generate the java-intellij-idea-and-maven-1.0-SNAPSHOT.jar file in the target directory.
After building the project, you can run the JAR file using the following command:
java -jar target/java-intellij-idea-and-maven-1.0-SNAPSHOT.jar "DAI student" hello --greetings "Bonjour"
The application has two subcommands: hello
and goodbye
. You can use the following options:
-
hello: Prints a greeting message.
--greetings
: Specify the greeting message (default: "Hello").
-
goodbye: Prints a farewell message.
--farewells
: Specify the farewell message (default: "Goodbye").
- Run the
hello
subcommand:java -jar target/java-intellij-idea-and-maven-1.0-SNAPSHOT.jar "DAI student" hello --greetings "Bonjour" output : Bonjour DAI student!
- Run the
goodbye
subcommand:java -jar target/java-intellij-idea-and-maven-1.0-SNAPSHOT.jar "DAI student" goodbye --farewells "Au revoir" output : Au revoir DAI student!