This week's book giveaway is in the General Computing forum.
We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line!
See this thread for details.
The moose likes Java in General and the fly likes system properties Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "system properties" Watch "system properties" New topic
Author

system properties

Tushar Kapila
Ranch Hand

Joined: Dec 23, 2007
Posts: 35

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?


http://thehungersite.com | http://www.worldcommunitygrid.org/
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19232

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.


SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
Jesper de Jong
Java Cowboy
Bartender

Joined: Aug 16, 2005
Posts: 12950
    
    3

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]

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Tushar Kapila
Ranch Hand

Joined: Dec 23, 2007
Posts: 35

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!
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: system properties
 
Similar Threads
hi problem in .exe
Problem with JFileChooser
Java in Windows and MacOS
A total newbie needing advice
Basics of Mac OS