0
I am testing a . jar where I will pass named parameters on the command line, etc. The problem is that you are not finding my main class. Somebody help me?
package appOptions;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.CommandLineParser;
import org.apache.commons.cli.DefaultParser;
import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;
public class Main {
public static void main(String[] args) throws ParseException {
Options options = new Options();
options.addOption("t", true, "Teste");
CommandLineParser parser = new DefaultParser();
CommandLine cmd = parser.parse( options, args);
if(cmd.hasOption("t")) {
System.out.println("Funcionou");
}
else {
System.out.println("Não funcionou");
}
}
}
And my file pom:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.roknauta</groupId>
<artifactId>appOptions</artifactId>
<version>0.0.1-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<archive>
<manifest>
<mainClass>com.roknauta.addOption.src.main.java.addOptions.Main</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
<version>1.3.1</version>
</dependency>
</dependencies>
</project>
I’ve changed course and nothing.
Try the plugin Maven-Assembly-plugin follows the documentation. https://maven.apache.org/guides/mini/guide-assemblies.html
– Henrique Luiz
Add your full class, including package name and Imports.
– Felipe Marinho
Ready @Felipemarinho
– Roknauta