wood burning stoves*
The moose likes Java in General and the fly likes system properties Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
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: 19651
    
  18

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 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14074
    
  16

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!
 
Consider Paul's rocket mass heater.
 
subject: system properties
 
Similar Threads
A total newbie needing advice
Java in Windows and MacOS
Basics of Mac OS
Problem with JFileChooser
hi problem in .exe