I need System.setProperty(String, String)

Hi;

I need to be able to set some system properties (for some unit tests). How do I do this In java it's System.setProperty("key", "value");

thanks - dave


Answer this question

I need System.setProperty(String, String)

  • TylerPenniman

    Hi David

    Thanks for the feedback. Your request for this JDK 1.2 level method in the future releases has been noted. Like all other requests from our customers about what they would like in our future releases, this request also would go through our planning/investigation process.

    With regards
    Ashwin Raja

  • wejaya

    To set custom values you will need to use System.setProperties() method
    passing the property table.

    Eg.

      java.util.Properties p = new java.util.Properties();
      p.setProperty("Hello", "Hi");
      System.setProperties(p);
      System.Console.Write(System.getProperty("Hello"));

    Hope this helps.

  • Stuart Dunkeld

    I have the following in my code:
    System.setProperty("key", "value");

    and the compiler says there is no setProperty(String, String) method.

    thanks - dave

  • inkisgod

    The following may be the right code.

    java.util.Properties p = System.getProperties();
    or
    java.util.Properties p = new java,util.Properties(System.getProperties());

    p.setProperty("Hello", "Hi");
    System.setProperties(p);
    System.Console.Write(System.getProperty("Hello"));


    The latter one has a performance problem when we set many properties.


  • N8WEI

    be specific please



  • JWallis

    Hi;

    That's what I am doing. And it's test code so the performance is not critical. But it's a pain to have to do this in 27 places. Please for .net 2.1 add this method as I am sure others will need this too (for common source code).

    thanks - dave

  • I need System.setProperty(String, String)