Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

System.getProperty trouble

 
Egil Poma
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have this simple program:
public class Server
{
public static void main(String[] args)
{
String data;
data = System.getProperty("path");
System.out.println(data);
}
}
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
Posts: 154
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Egil, try this:
java -Dpath=optional_parameter Server -Dpath=command_line_argument
System.out.println( System.getProperty("path") );
System.out.println( args[0] );
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic