java program to pass VM/JVM parameters through CMD



Contents of page :
  • 1) Writing and executing java program through CMD in windows >
  • 2) Now, we will pass VM parameters to java program through CMD >
    • Example 1 (Passing single JVM parameters)  - Passing -Xms
    • Example 2  (Passing single JVM parameters)  - Passing -Xmx
    • Example 3 (Passing multiple VM/JVM parameters) - Passing -Xms and -Xmx


1) Writing and executing java program through CMD in windows >
Let’s write first class >
public class MyJavaProgram {
public static void main(String[] args) {
    System.out.println("This is my Java Program");
}
}

Let’s say above code in file =  E:\MyJavaProgram.java

Go to CMD and type below commands >
C:\Users\ankitmittal01>e:

E:\>javac MyJavaProgram.java

E:\>

Directory of .class file = E:\MyJavaProgram.class


2) Now, we will pass VM parameters to java program through CMD >

Example 1 (Passing single JVM parameters)  - Passing -Xms

E:\>java -Xms512m MyJavaProgram
This is my Java Program

E:\>


Example 2  (Passing single JVM parameters)  - Passing -Xmx

E:\>java -Xms512m  -Xmx1024m MyJavaProgram
This is my Java Program

E:\>


Example 3 (Passing multiple VM/JVM parameters) - Passing -Xms and -Xmx

E:\>java -Xms512m  -Xmx1024m MyJavaProgram
This is my Java Program

E:\>




Learn how to pass vmargs (VM parameters) to java program in eclipse?





SUMMARY>
So in this core java tutorial we learned how to write java program to pass VM/JVM parameters through CMD.


Having any doubt? or you liked the tutorial! Please comment in below section.
Please express your love by liking JavaMadeSoEasy.com (JMSE) on facebook, following on google+ or Twitter.



/** Copyright (c), AnkitMittal JavaMadeSoEasy.com */

RELATED LINKS>

What is eclipse.ini file? How to pass vmargs to java program in eclipse? Changing the eclipse setting, What are best eclipse setting?


Download and install JDK, Setting environment variables JAVA_HOME & JDK PATH temporarily and permanently in windows, What is a path? need to set PATH variable?


Writing and executing first java program through CMD in windows, Setting up ECLIPSE in java, Directory of .class file

Most important and frequently used VM (JVM) PARAMETERS with examples in JVM Heap memory in java


Interface in java

Abstract class in java

Constructor in java


eEdit
Must read for you :