Results 1 to 7 of 7
  1. #1
    Suresh V is offline Member
    Join Date
    Oct 2010
    Posts
    3
    Rep Power
    0

    Default Setting System Property in Mac OS

    Hi,
    I am trying to set a custom property in my System variables from my terminal( command prompt) in Mac OS

    ex :: java -Dlog.logdir="logs"

    not sure why it is not setting that in the system properties when trying to retrieve it from the class

    ex :: String prop = System.getProperty("log.logdir");

    Please let me know what i am missing while setting the property from Terminal (command prompt).

    Thanks in Advance!

  2. #2
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,565
    Rep Power
    12

    Default

    The -D part looks OK, but the command you mention does not involve a class. Perhaps you could post a small compilable example along with the command to execute it and its output.

  3. #3
    Suresh V is offline Member
    Join Date
    Oct 2010
    Posts
    3
    Rep Power
    0

    Default

    Thanks for the reply pbrockway2.

    But what exactly do you mean by 'does not involve a class' ?

    When i did java -Dlog.logdir="logs", i wanted to set this property for all my classes in the workspace. Please let me know how can i do that.

  4. #4
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,565
    Rep Power
    12

    Default

    I see! -Dlog.logdir="logs" sets the property for the application being run by the java command. (The command you posted will just result in an error/usage message).

    I don't know what you mean by "workspace". Is some sort of IDE involved?

  5. #5
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,519
    Blog Entries
    7
    Rep Power
    20

    Default

    When the JVM is gone (the process has stopped) all the system properties have gone.

    kind regards,

    Jos

  6. #6
    Suresh V is offline Member
    Join Date
    Oct 2010
    Posts
    3
    Rep Power
    0

    Default

    pbrockway2 :: I am using Eclipse IDE


    JosAH , So you mean i cannot save the custom properties permanantly?. Why i am asking you this is, i need to set a custom property and wanted to use it with the groovy code which in turn calls my web services. And my groovy code fails because it cannot find the property which is set from my command prompt.

    I am totally confused here. I apologize if i am confusing you all :(

  7. #7
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,006
    Rep Power
    20

    Default

    If you were to run this from the command line you would use something like:
    java -Dlog.logdir="logs" <name of main class>

    That's how the property is set when the program runs.

    There'll be something in Eclipse for setting up run parameters, where you can add the -Dlog.logdir="logs" to.

Similar Threads

  1. Replies: 0
    Last Post: 06-25-2009, 05:28 AM
  2. setting system clocks time
    By pks in forum New To Java
    Replies: 4
    Last Post: 05-14-2009, 03:36 AM
  3. JAVA -Setting system variables for Vista
    By vertesi in forum New To Java
    Replies: 3
    Last Post: 03-20-2009, 08:10 AM
  4. where is the system.property
    By osval in forum Advanced Java
    Replies: 2
    Last Post: 08-06-2007, 03:54 AM
  5. Replies: 1
    Last Post: 07-24-2007, 12:26 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •