1

I have sample code downloaded from here for using jscience.

But when I use it, it gives this message:

E/AndroidRuntime(1296): java.lang.NoClassDefFoundError:org.jscience.mathematics.function.Variable$Local

Am I missing something? Of course I imported the jscience jar lib to my project. But still can't figure this out.

    Variable.Local<Rational> varX = new Variable.Local<Rational>("x");
    Variable.Local<Rational> varY = new Variable.Local<Rational>("y");

    // f(x, y) =  x² + x·y + 1;
    Polynomial<Rational> x = Polynomial.valueOf(Rational.ONE, varX);
    Polynomial<Rational> y = Polynomial.valueOf(Rational.ONE, varY);
    Polynomial<Rational> fx_y = x.pow(2).plus(x.times(y)).plus(Rational.ONE);
    System.out.println("f(x,y) = " + fx_y);

    // Evaluates f(1,0) 
    System.out.println("f(1,0) = " + fx_y.evaluate(Rational.ONE, Rational.ZERO));

    // Calculates df(x,y)/dx
    System.out.println("df(x,y)/dx = " + fx_y.differentiate(varX));
jerry
  • 2,581
  • 1
  • 21
  • 32
max
  • 5,963
  • 12
  • 49
  • 80

1 Answers1

1

The class org.jscience.mathematics.function.Variable$Local is definitely in the JAR:

$ jar tf JScience/lib/jscience.jar | grep Variable\$Local
org/jscience/mathematics/function/Variable$Local.class

Verify that the required libraries are listed in the Class-Path attribute in your JAR's manifest; use a tool like the one cited here to be sure:

Class-Path: lib/jscience.jar lib/javolution.jar …

Addendum: As noted in a comment by @max, the ADT 17 library directory should be named libs.

Community
  • 1
  • 1
trashgod
  • 203,806
  • 29
  • 246
  • 1,045
  • thanks for your attention but i did't get what i have to do? can you explain more about this ? – max May 24 '14 at 00:36
  • ok thanks. i found my fault. i have to change my library folder from lib to libs and clean my project. http://android.foxykeep.com/dev/how-to-fix-the-classdefnotfounderror-with-adt-17 – max May 24 '14 at 01:05
  • @max: Glad you got it sorted. – trashgod May 24 '14 at 02:51