Home » Java programming language

Java System class setProperties() method with example

System class setProperties() method: Here, we are going to learn about the setProperties() method of System class with its syntax and example.
Submitted by Preeti Jain, on September 12, 2019

System class setProperties() method

  • setProperties() method is available in java.lang package.
  • setProperties() method is used to set the current system properties of the given parameter (system_property).
  • setProperties() method is a static method, so it is accessible with the class name too.
  • setProperties() method throws a SecurityException at the time of setting the system properties:
    SecurityException: In this exception, its checkPermission() method can’t allow access to the given system properties when the security manager exists.

Syntax:

    public static void setProperties(Properties system_property);

Parameter(s):

  • system_property – represents the new system property.

Return value:

The return type of this method is void, it does not return any value.

Example:

// Java program to demonstrate the example of 
// setProperties () method of System Class.

import java.lang.*;
import java.util.Properties;

public class SetPropertiesMethod {
    public static void main(String[] args) {
        //Display previous operating system architecture 
        //before setting properties
        System.out.print("Previous Architecture :" + " ");
        System.out.print(System.getProperty("os.arch"));

        Properties prop = System.getProperties();
        prop.put("os.arch", "Hybrid Kernel");
        System.setProperties(prop);

        System.out.println();

        //Display new operating system architecture 
        //after setting properties
        System.out.print("New Architecture :" + " ");
        System.out.print(System.getProperty("os.arch"));
    }
}

Output

E:\Programs>javac SetPropertiesMethod.java
E:\Programs>java SetPropertiesMethod
Previous Architecture : amd64
New Architecture : Hybrid Kernel






Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.




Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates


© https://www.includehelp.com some rights reserved.