Hello! In general, I wanted to write applications for interacting with Yandex Disk, I found code that works with the help of the Java DAV library (Sardine). I downloaded the library, launched the verification code (should display a list of files on disk):

public static void main(String[] args){ String URL = "https://webdav.yandex.ru/"; String login = "some login"; String pswd = "some password"; Sardine sardine = SardineFactory.begin(login, pswd); for (DavResource res : sardine.getResources(URL)) { System.out.println(res.getName()); } } 

And got this:

 Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/http/client/RedirectStrategy at com.github.sardine.SardineFactory.begin(SardineFactory.java:45) at com.github.sardine.SardineFactory.begin(SardineFactory.java:35) at Disk.main(Disk.java:25) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147) Caused by: java.lang.ClassNotFoundException: org.apache.http.client.RedirectStrategy at java.net.URLClassLoader.findClass(URLClassLoader.java:381) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ... 8 more 

I understand that the project does not have enough org / apache / http / client / RedirectStrategy, I downloaded it, added it to Classpath, and nothing, everything is the same. Please tell me what to do in this situation?

  • How did you connect the library? - post_zeew
  • I use Intellij Idea 16, there the libraries are connected in the project settings, i.e. do not need to enter anything into the console - Alex
  • one
    I have now connected this library through maven and when executing your code I received an authorization error (which is quite understandable). There were no other errors. - post_zeew
  • hmm, strange, but you couldn’t throw off the link to the place where you downloaded the library, just in case I downloaded a curve - Alex
  • one

1 answer 1

Add the library as follows:

File - Project Structure - Libraries - Add - From Maven - com.github.lookfirst:sardine:5.7

enter image description here