title: Why getProperty method doesn't print out the working directory?
body: <p>I am trying to build a simple client-server aplication. Now I want to print out the current working directory of the server. I have tried by using  <code>String workingDir=  System.getProperty("user.dir");</code> method. But it doesn't actually print out the directory. I don't know why. I need help.</p>
  
  <pre><code>   package clint;
  import java.io.*;
  import java.net.*;
  import java.util.Scanner;
  
  public class AreaClient{
     private static final int PORT = 8000;
      private static final String SERVER = "194.47.46.146";
  
      public static void main ( String [] args ){
         String server = "localhost";
         int port = PORT;
  
          if ( args.length &gt;= 1 )
            server = args[0];
          if (args.length &gt;= 2)
            port = Integer.parseInt( args[1]);
  
          new AreaClient ( server, port ); 
      }
  
      public AreaClient( String server, int port ){
        DataInputStream inputFromServer;
        DataOutputStream outputToServer;
  
        try {
          // create a socket to connect to the server
          Socket socket = new Socket( server, port );
  
           // create data input/output streams
           inputFromServer = new DataInputStream( socket.getInputStream( ) );
           outputToServer = new DataOutputStream( socket.getOutputStream( ) );
  
           // create Scanner object to read command from the keyboard
           Scanner sc = new Scanner ( System.in );
           System.out.print("Enter pwd command = ");
           while ( sc.hasNext()){
              // get the pwd command
               String command = sc.nextLine();
  
               // send the pwd command to sever
               outputToServer.writeBytes(command );
               outputToServer.flush( );
  
               // get working directory from server
               String workingDir = inputFromServer.readUTF();
  
               System.out.println("Working directory is: " + workingDir);
  
           }
           inputFromServer.close();
           outputToServer.close();
           socket.close( );
          } catch ( IOException e ){
            System.err.println( e );
          }
  
      }
  
  }
  
  
  
  
  package server;
  import java.io.*;
  import java.net.*;
  
  public class AreaServer{
     private static final int PORT = 8000;
      private ServerSocket serverSocket;
  
      public static void main ( String [] args ){
         int port = PORT;
          if ( args.length == 1 )
             port = Integer.parseInt( args[0] );  
          new AreaServer( port );
      }
  
      public AreaServer( int port ){
        // create a server socket
        try {
            serverSocket = new ServerSocket( port );
        } catch ( IOException e ) {
           System.err.println( "Error in creation of the server socket");
            System.exit( 0 );
        }
  
        while ( true ) {
          try {
             // listen for a connection
              Socket socket = serverSocket.accept( ) ;
  
               // create data input/output streams
               DataInputStream inputFromClient = new DataInputStream( socket.getInputStream( ));
              DataOutputStream outputToClient = new DataOutputStream( socket.getOutputStream( ) );
  
               // loop to service a client
              while ( true ){
                  //receive command from client
                String command = inputFromClient.readUTF();
  
                //getting the directory
                String workingDir=  System.getProperty("user.dir");
  
                //send the working directory to client
                outputToClient.writeBytes(workingDir );
               } 
  
              } catch ( IOException e ){
                System.err.println( e );
              }
          }
      }
  }
  </code></pre>