This week's book giveaway is in the JDBC forum.
We're giving away four copies of Make it so: Java DB Connections & Transactions and have Marcho Behler on-line!
See this thread for details.
The moose likes Java in General and the fly likes System.getProperty trouble Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Make it so: Java DB Connections & Transactions this week in the JDBC forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "System.getProperty trouble" Watch "System.getProperty trouble" New topic

System.getProperty trouble

Egil Poma
Ranch Hand

Joined: Nov 23, 2002
Posts: 40
I have this simple program:
public class Server
public static void main(String[] args)
String data;
data = System.getProperty("path");
If I start this program like this:
java Server -Dpath=whatever
It prints out 'null'.
No matter what value i put after '=' it only prints 'null'. Am I doing something wrong here or is it something else?
I'm using jdk 1.4.0_02
[ November 23, 2002: Message edited by: Egil Poma ]
Vin Kris
Ranch Hand

Joined: Jun 17, 2002
Posts: 154
Egil, try this:
java -Dpath=optional_parameter Server -Dpath=command_line_argument
System.out.println( System.getProperty("path") );
System.out.println( args[0] );
I agree. Here's the link:
subject: System.getProperty trouble
It's not a secret anymore!