Image

Imagesmesh wrote in Imageru_java

[Tip of the day][Очередное извращение] Return a Property Without System.getProperty


Return a Property Without System.getProperty

On the JVM, System.getProperty()
will only return a property if that property has been set using the -D
flag. But what if a property has been set using EXPORT on a UNIX
platform? Use this code to return the property:

Process p = null;
                try
                {
                        p = Runtime.getRuntime().exec("env");
                        java.util.Properties pr = new java.util.Properties();
                        pr.load(p.getInputStream());
                        System.out.println("Property : " + pr.getProperty(propName));
                }
                catch(Exception e)
                {
                        e.printStackTrace();
                }
>>>