17

I have tried below ways but nothing work... i am trying to access jmx remotely from server.

         <jvmArgs>
         <jvmArg>-Dcom.sun.management.jmxremote.port=9999</jvmArg>
        <jvmArg>-Dcom.sun.management.jmxremote.authenticate=false</jvmArg>
          <jvmArg>-Dcom.sun.management.jmxremote.ssl=false</jvmArg>
        </jvmArgs>

        <!-- <systemPropertyVariables> 
                                   <com.sun.management.jmxremote.port>9999</com.sun.management.jmxremote.port> 
                       <com.sun.management.jmxremote.authenticate>false</com.sun.management.jmxremote.a uthenticate> 
                     <com.sun.management.jmxremote.ssl>false</com.sun.management.jmxremote.ssl> 
                 </systemPropertyVariables> -->

                 <!-- <jvmArguments> 
                 <jvmArgument>- Dcom.sun.management.jmxremote.port=9999</jvmArgument> 
                 <jvmArgument>- Dcom.sun.management.jmxremote.authenticate=false</jvmArgument> 
                 <jvmArgument>- Dcom.sun.management.jmxremote.ssl=false</jvmArgument> 
                </jvmArguments> -->

I also tried

 <options>
            <option>-Dcom.sun.management.jmxremote.port=9999</option> 
            <option>-Dcom.sun.management.jmxremote.authenticate=false</option> 
            <option>-Dcom.sun.management.jmxremote.ssl=false</option> 
            </options>
Rahul sharma
  • 399
  • 1
  • 5
  • 14
  • for what do you want to add the vmargs? Compiling, testing, running your application? With what maven goal do you do this? You should show more of your pom. – P.J.Meisch Sep 28 '16 at 18:12

2 Answers2

45

You can do this in few different ways.

Using the Maven Compiler Plugin
You can use the compilerArgs property of the plugin to specify the Xmx, Xms, Xss VM arguments.
Below is an example

<project>
    [...]
    <build>
      [...]
      <plugins>
        <plugin>
           <groupId>org.apache.maven.plugins</groupId>
           <artifactId>maven-compiler-plugin</artifactId>
           <version>3.10.1</version>
           <configuration>
             <compilerArgs>
                  <arg>-Xmx512M</arg>   // You can provide comma separated values if you have more than one
             </compilerArgs>
          </configuration>
        </plugin>
       </plugins>
       [...]
    </build>
    [...]
</project>

Refer to the Maven Compiler Plugin for more details.

Using the Maven Surefire Plugin
You can use the argLine property of the plugin to specify the Xmx, Xms, Xss VM arguments.
Below is an example

</project>    
    [...]
    <build>
      [...]
      <plugins>
        <plugin>
           <groupId>org.apache.maven.plugins</groupId>
           <artifactId>maven-surefire-plugin</artifactId>
           <version>3.0.0-M7</version>
           <configuration>
                <argLine>-Xmx512M</argLine>   // You can provide comma separated values if you have more than one
           </configuration>
         </plugin>
       </plugins>
       [...]
    </build>
    [...]
</project>

Refer to the Maven Surefire Plugin for more details.

Christoph John
  • 3,003
  • 2
  • 13
  • 23
RITZ XAVI
  • 3,633
  • 1
  • 25
  • 35
0

Can be done in POM file as follows :

  <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <forkCount>1</forkCount>
                    <reuseForks>false</reuseForks>
                    <argLine>
                        --add-opens=java.base/java.lang=ALL-UNNAMED
                        --add-opens=java.base/java.lang.invoke=ALL-UNNAMED
                        --add-opens=java.base/java.lang.reflect=ALL-UNNAMED
                        --add-opens=java.base/java.io=ALL-UNNAMED
                        --add-opens=java.base/java.net=ALL-UNNAMED
                        --add-opens=java.base/java.nio=ALL-UNNAMED
                        --add-opens=java.base/java.util=ALL-UNNAMED
                        --add-opens=java.base/java.util.concurrent=ALL-UNNAMED
                        --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED
                        --add-opens=java.base/sun.nio.ch=ALL-UNNAMED
                        --add-opens=java.base/sun.nio.cs=ALL-UNNAMED
                        --add-opens=java.base/sun.security.action=ALL-UNNAMED
                        --add-opens=java.base/sun.util.calendar=ALL-UNNAMED
                        --add-opens=java.security.jgss/sun.security.krb5=ALL-UNNAMED
                        --add-exports java.base/sun.nio.ch=ALL-UNNAMED
                    </argLine>
                </configuration>
            </plugin>
Tohid Makari
  • 1,700
  • 3
  • 15
  • 29