You are here : Home / Core Java Tutorials / Series of JVM and Garbage Collection (GC) in java - Best explanations ever
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:\>
|
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>