I am new to maven and facing problems while running a class file through maven
It runs fine with
mvn exec:java -Dexec.mainClass="com.test.Test"
But not with
mvn exec:exec -Dexec.executable=java -Dexec.mainClass="com.test.Test"
It asks for java parameters
F:\data\work\Test>mvn exec:exec -Dexec.executable=java -Dexec.mainClass="com.test.Test"
Usage: java [-options] class [args...]
(to execute a class)
or java [-options] -jar jarfile [args...]
(to execute a jar file)
where options include:
-d32 use a 32-bit data model if available
-d64 use a 64-bit data model if available
-server to select the "server" VM
-hotspot is a synonym for the "server" VM [deprecated]
The default VM is server.
-cp <class search path of directories and zip/jar files>
-classpath <class search path of directories and zip/jar files>
A ; separated list of directories, JAR archives,
and ZIP archives to search for class files.
I am already providing a class file then why its not able to pick that? I tried providing those even through pom.
I am using exec:exec as I dont want to pass VM arguments from MAVEN_OPTS
here is my pom
<profiles>
<profile>
<id>fib</id>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.3.2</version>
<executions>
<execution>
<phase>test</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<mainClass>com.test.Test</mainClass>
<executable>java</executable>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
What am I missing?
So 2 questions which arises -
1)What am I missing s that its asking me to pass java parameters despite of passing mainClass?
2)How can I pass VM arguments using exec-maven-plugin?
I have found this for my 2nd question using maven 'exec:exec' with arguments
mvn exec:exec -Dexec.executable=java -Dexec.args="-classpath target/classes -XX:+PrintGCDetails com.test.Test"
also if you are concerned about dependencies being in classpath then make a fat jar and set it in classpath
interesting discussion: https://chat.stackoverflow.com/rooms/67085/discussion-between-biker-and-jigar-joshi