How to access the command line args passed from Maven in the Java program

<>

This question already has an answer here:

Answers


There is no easy way to access command line arguments. The usual workaround is to use System properties instead:

    <configuration>
      <mainClass>com.example.Main</mainClass>
      <systemProperties>
        <systemProperty>
          <key>timestamp</key>
          <value>023012</value>
        </systemProperty>
        <systemProperty>
          <key>currentdate</key>
          <value>01292014</value>
        </systemProperty>
        ...
      </systemProperties>
    </configuration>

You can access these anywhere using System.getProperties()

Related articles:


Need Your Help

How to enable Kerberos authentication for remote EJB call on WebSphere?

java java-ee ejb websphere kerberos

My application is a stand-alone Swing client invoking EJB Stateless Session beans thanks to classical JNDI lookup and RMI-IIOP method calls. It is started as a Java WebStart application. My aim is to