All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jerkar.tool.JkUtilsTool Maven / Gradle / Ivy

There is a newer version: 0.7.0.RELEASE
Show newest version
package org.jerkar.tool;

import java.io.File;
import java.util.HashMap;
import java.util.Map;

import org.jerkar.api.system.JkLocator;
import org.jerkar.api.utils.JkUtilsFile;

/**
 * Utilities related to running piece of code outside of the tool itself.
 */
public final class JkUtilsTool {

    static Map userSystemProperties() {
        final Map result = new HashMap();
        final File userPropFile = new File(JkLocator.jerkarUserHome(), "system.properties");
        if (userPropFile.exists()) {
            result.putAll(JkUtilsFile.readPropertyFileAsMap(userPropFile));
        }
        return result;
    }

    static void setSystemProperties(Map props) {
        for (final Map.Entry entry : props.entrySet()) {
            System.setProperty(entry.getKey(), entry.getValue());
        }
    }

    /**
     * Set the properties defined in Jerkar user directory into the system.
     */
    public static void loadUserSystemProperties() {
        setSystemProperties(userSystemProperties());
    }

    private JkUtilsTool() {
        // Can't instantiate
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy