• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

system properties

 
Ranch Hand
Posts: 36
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
this is for standalone apps and j2ee

i assumed that System.getProperties() also returns properties set by us in the OS variables. especially as i read that on MAC that is the only way to send options to java as program arguments are not supported.

but it seems we must send user properties as -DpropName=value1

even though the batch program starting java can see the OS property we are interested in.

if anyone has mac - is this the case with java on mac too?

shouldn't java pass us all OS properties? it does initialize user.dir , user name etc from windows so why not take all?
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Because these were not regarded as necessary. Since Java 5.0 you can use System.getenv() or System.getenv(String property) for this. Actually you could use the latter before Java 5.0 as well although it was deprecated in Java 1.4.
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tushar Kapila wrote:especially as i read that on MAC that is the only way to send options to java as program arguments are not supported.


Where did you read that? Maybe you didn't understand correctly what was meant? You can pass arguments to a Java program on a Mac when running it from the command prompt just like on Windows, Linux or other operating systems.

Works fine on my Mac:

> javac Example.java
> java Example hello world
args = [hello, world]
 
Tushar Kapila
Ranch Hand
Posts: 36
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
mac args -read it in an email from a client ... maybe it was arguments in a short cut to java ?

anyway good to know about getEnv
thank you!
 
reply
    Bookmark Topic Watch Topic
  • New Topic