Home > Software engineering >  Maven no print output when compiling
Maven no print output when compiling

Time:04-01

As I understand it the lifecycle is as follows.

validate compile test package verify install deploy

However when I compile I do not get a print output. The only way seems to be from calling unit tests however I was looking for away to just compile my code as I work and see the output. Would be super grateful if anyone could shed light on this for me.

Thank you

package com.desocial;

/**
 * Inside app.java
 */
public final class App {
    private App() {
    }

    /**
     * Says hello to the world.
     * @param args The arguments of the program.
     */
    public static void main(String[] args) {
        System.out.print("No print output");
    }
}

CodePudding user response:

you can use the maven exec plugin to execute your main class, for example:

mvn clean compile exec:java -Dexec.mainClass=com.desocial.App

In that case, you will see the output of your code:

...
[INFO] --- exec-maven-plugin:3.0.0:java (default-cli) @ app ---
No print output
...
  • Related