title: Copy shared folder from windows to linux using JCIFS Java
body: <p>I want to copy shared windows folder to linux (running on VM).I am using JCIFS SMB Framework</p>
  
  <p><strong><em>Code</em></strong></p>
  
  <pre><code>package pkg;
  import java.net.MalformedURLException;
  
  import jcifs.smb.*;
  
  public class FolderCopy {
  
  /**
   * @param args
   */
  public static void main(String[] args) {
      try{
      //This is windows shared folder path
       String urlToBackUpFile = "smb://ip/Share"; 
       System.out.println("smb folder of source file" + urlToBackUpFile);
       NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication("domain", "username", "password");
  
  
         SmbFile dir = new SmbFile(urlToBackUpFile, auth);
         System.out.println(dir.getDate());
       //This is linux path where I want to copy.
         SmbFile dest = new SmbFile ("file:///home/cloudera/Desktop/Test",auth);
         dir.copyTo(dest);
      // TODO Auto-generated method stub
      }
      catch (MalformedURLException e1) {
          e1.printStackTrace();
      }
      catch (SmbException e1) {
          e1.printStackTrace();
      }
  
  }
  
  }
  </code></pre>
  
  <p><strong><em>Exception</em></strong></p>
  
  <pre><code>jcifs.smb.SmbException: Failed to connect to server
  java.net.UnknownHostException: ..__MSBROWSE__.&lt;01&gt;
      at jcifs.netbios.NbtAddress.doNameQuery(NbtAddress.java:308)
      at jcifs.netbios.NbtAddress.getByName(NbtAddress.java:413)
      at jcifs.netbios.NbtAddress.getByName(NbtAddress.java:394)
      at jcifs.smb.SmbFile.getAddress(SmbFile.java:749)
      at jcifs.smb.SmbFile.connect(SmbFile.java:790)
      at jcifs.smb.SmbFile.connect0(SmbFile.java:767)
      at jcifs.smb.SmbFile.copyTo(SmbFile.java:2112)
      at pkg.FolderCopy.main(FolderCopy .java:22)
  
      at jcifs.smb.SmbFile.connect0(SmbFile.java:769)
      at jcifs.smb.SmbFile.copyTo(SmbFile.java:2112)
      at pkg.FolderCopy .main(FolderCopy .java:22)
  </code></pre>
  
  <p>I Referred this : <a href="https://stackoverflow.com/questions/13359164/how-to-copy-file-from-smb-share-to-local-drive-using-jcifs-in-java">How to copy file from smb share to local drive using jcifs in Java?</a></p>