Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are several command line parameters of the JAVA virtual machine

2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article will explain in detail what the command line parameters of the JAVA virtual machine are, and the content of the article is of high quality, so the editor will share it with you for reference. I hope you will have a certain understanding of the relevant knowledge after reading this article.

I. run the class file

Execute the class file with the main method, command behavior:

Java

Note: do not have a file suffix for CLASS filename. Class

For example:

Java Test

If the executed class file is packaged, that is, it is used in the class file:

Package

That should be executed under the base path of the package, command behavior:

Java .class file name

For example:

In PackageTest.java, the package name is: com.ee2ee.test, and the corresponding statement is:

Package com.ee2ee.test

The directory where PackageTest.java and the compiled class file PackageTest.class are stored is as follows:

Classes

| | _ com |

| | _ ee2ee |

| | _ test |

| | _ PackageTest.java |

| | _ PackageTest.class |

To run PackageTest.class, execute it under the classes directory:

Java com.ee2ee.test.PackageTest

2. Run class in jar file

The principle is the same as running a class file, just add the parameter-cp.

For example, execute the class com.ee2ee.test.PackageTest in test.jar. The command line is as follows:

Java-cp test.jar com.ee2ee.test.PackageTest

3. Display jdk version information

When there are multiple versions of jdk on a machine, you need to know which version of jdk is currently being used. Use the parameter-version to know the version. Command behavior:

Java-version

Fourth, increase the maximum memory that can be used by virtual machines

The maximum memory that a java virtual machine can use is limited, and the default value is usually 64MB or 128MB.

If an application loads data into memory in order to improve performance, such as exceeding the default maximum value of 128MB, you need to increase the maximum memory available to the java virtual machine, otherwise there will be an Out of Memory (system out of memory) exception. When starting java, you need to use the following two parameters:

-the amount of memory used during initialization of the Xms java virtual machine

-maximum memory that can be used by the Xmx java virtual machine

The size set in the above two parameters can be in units. For example, 256m represents 256MB.

Examples are as follows:

Java-Xms128m-Xmx256m...

Indicates that the memory used for initialization of the java virtual machine is 128MB, and the maximum memory available is 256MB.

For tomcat, you can modify its script catalina.sh (unix platform) or catalina.bat (windows platform) by setting the variable JAVA_OPTS, for example:

JAVA_OPTS='-Xms128m-Xmx256m' on the JAVA virtual machine on several command-line parameters are shared here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report