public static String pipelineHome(String plUser, String plPort){
        StringBuilder homePath = new StringBuilder();

         // By getting the owner of the preferences file we can get the Pipeline user.
        Process p = null;
        try {
            String s = "";

            if ( !plUser.equals("root") ) {
                String [] cmd = {"/bin/sh","-c","echo ~" + plUser};
                p = Runtime.getRuntime().exec(cmd);

                BufferedReader stdInput = new BufferedReader(new InputStreamReader(p.getInputStream()));

                String [] tokens = null;
                
                s = stdInput.readLine();

                stdInput.close();
            }
            homePath.append(s);
        } catch ( Exception ex ) {
            ex.printStackTrace();
        } finally {
            if ( p != null )
                NativeCalls.releaseProcess(p);
        }


        homePath.append(File.separator);

        if (isOSX) //In OSX pipeline home directory should be in "~/Library/Preferences/"
            homePath.append("Library" + File.separator + "Preferences");
        else if (isVista || isWinSeven) //In Windows Vista or Seven pipeline home directory should be in "$HOME\AppData\Local\LONI\"
            homePath.append("AppData" + File.separator + "Local" + File.separator + "LONI");
        else if (isWindows) //In pipeline home directory should be in "$HOME\Application Data\LONI\"
            homePath.append("Application Data" + File.separator + "LONI" + File.separator);

        // Unix home directory should be "~/.pipeline/"
        if (isLinux || isSolaris) {
            homePath.append(".pipeline"); // Add dot before pipeline directory name to make it hidden
        }
        else {
            homePath.append(File.separator);
            homePath.append("Pipeline");
        }

        homePath.append(File.separator);
        homePath.append( plPort );


        homePath.append(File.separator);

        return homePath.toString();
    }