public static void main(String[] args)
{
System.out.println("Hello World");
}
Now open the pom.xml file created in the project and add the following section to the end:
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>java</executable>
<includeProjectDependencies>true</includeProjectDependencies>
<includePluginDependencies>false</includePluginDependencies>
<classpathScope>exec</classpathScope>
<mainClass>com.trying.hello_world.App</mainClass>
</configuration>
</plugin>
</plugins>
</build>
Save and close pom.xml. Now navigate the project root folder, then compile and execute the program in the terminal:
> cd $PROJECT_HOME/hello-world > mvn compile exec:java
You should see the output "Hello World" as well as messages indicating the project is built successfully (the output classes are in the hello-world/target sub folder).
No comments:
Post a Comment