jimmoores / quandl4j

Java wrapper for Quandl REST API

Home Page:quandl4j.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

NoClassDefFoundError: QuandlSession or NoClassDefFoundError: ClassicQuandlSession

stefanionescu opened this issue · comments

Hi,

I'm trying to use your lib in Android Studio in a Java module that I made. I use gradle to get your code and then when I try to run either Example1 or Example2 I get this error:

Exception in thread "main" java.lang.NoClassDefFoundError: com/jimmoores/quandl/QuandlSession
at com.demo.constant.volatilecommodities.Volatile.main(Volatile.java:14)
Caused by: java.lang.ClassNotFoundException: com.jimmoores.quandl.QuandlSession
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)
... 1 more

With either QuandlSession or ClassicQuandlSession.

What do I do wrong?

Gradle:


    apply plugin: 'java-library'

    dependencies {
      implementation fileTree(dir: 'libs', include: ['*.jar'])

      compile 'com.jimmoores:quandl-core:2.0.0'
    }

    sourceCompatibility = "1.7"
    targetCompatibility = "1.7" 

Actual code:

      public class myClass {

       public static void main(String[] args) {

        ClassicQuandlSession session = ClassicQuandlSession.create();
        TabularResult tabularResult = session.getDataSet(
                DataSetRequest.Builder.of("WIKI/AAPL").build());
        System.out.println(tabularResult.toPrettyPrintedString());
        }
    }  

Tried with runtime but it doesn't do the trick

It looks to me like your Gradle set-up isn't working. I'm not familiar with Gradle really but have you checked the libs directory to see if Gradle is actually pulling the library from maven central?

I see you're using the java-library plug-in. You might try the straight-up 'java' plug-in which doesn't require api and implementation separation (docs say that compile is supported but shouldn't be used).

As for what the part saying:

implementation fileTree(dir: 'libs', include: ['*.jar'])

do you know what that's doing?

I can try with simple "java". The implementation part compiles jars which are in the libs folder.

In the worst case, I'll make a separate lib that works in Android Studio

According to the Gradle docs for java-library you should have implementation 'com.jimmoores:quandl-core:2.0.0' instead of compile 'com.jimmoores:quandl-core:2.0.0'

runtime definitely won't work

Ultimately though this is a Gradle question and not a quandl4j question, so I'm going to close this issue