what are custom jvm properties?

后端 未结 3 1358
闹比i
闹比i 2021-01-14 04:01

I am new to Java and I have come across the term \"custom JVM properties\" and how to run configurations with custom JVM properties in eclipse. I want to understand what it

相关标签:
3条回答
  • 2021-01-14 04:15

    You can configure custom JVM properties to run your application by specifying them in Run Configurations. Follow the below steps to configure:

    • Right click the project. Click Run as then Run Configurations
    • Goto Arguments tab and give your custom parameters in the VM Arguments box
    • You can use the same set of configurations as default when running the project.
    0 讨论(0)
  • 2021-01-14 04:24

    If you are just starting out, this is not something you need to worry about or something that will affect you at all. JVM parameters are ways that you can tune the JVM for your program. The most common use for these is to adjust the memory used by Java or tune Garbage Collection algorithm.

    0 讨论(0)
  • 2021-01-14 04:41

    "jvm properties" concept is a way of making a property (name/value pair) JVM wide. Once you pass a property to the jvm, it becomes accesible in every point of that jvm.

    how to pass a property to a jvm:

    you can pass properties by command line (-Dproperty_name1=property_value1 -Dproperty_name2=property_value2 ...) at jvm startup,

    or

    in a running jvm by calling System.getProperties().load(inputStream) from a property file.

    or

    in a running jvm by calling System.setProperty("property_name1", "property_value1")

    how to reach that property:

    either way, these properties become JVM wide and you can reach them in every point of your application by calling System.getProperty("property_name1") ...

    this docement may help you understanding the properties concept and usage.

    example:

    package so;
    public class SomeClass {
        public void someMethod() {
            System.setProperty("my_pet_name", "boomerang");
        }
    }
    

    after calling someMethod() at any point in your application, then you can read it in any other class like this:

    package so;
    public class SomeOtherClass {
        public void someOtherMethod() {
            String myPetName = System.getProperty("my_pet_name");
            System.out.println(myPetName);
        }
    }
    
    0 讨论(0)
提交回复
热议问题