Sorin
Sorin

Reputation: 125

create custom java object from octave - ClassNotFoundException

I have written a simple custom java class

public class Optim {

public int optfunc(int x1, int x2, int x3, int x4, int x5, int x6)
{
    return (x1^2 + x2^2 +2*x3^2 + 2*x1*x2+x1*x3-200*x1- 140*x2 + 120*x3+200);
}

}

Now I want to create an object of type Optim in Octave. I have created a file called javaclasspath.txt which contains only one line

C:\Users\Sorin\Optim.class

and put this file in C:\Users\Sorin along with the file Optim.class When I start Octave I can see the following

>javaclasspath
STATIC JAVA PATH

  C:\Users\Sorin\Optim.class
  C:\Users\Sorin\Optim.class
 DYNAMIC JAVA PATH

  - empty -
>pwd
ans = C:\Users\Sorin
>x = javaObject('Optim')
error: [java] java.lang.ClassNotFoundException: Optim

Do you have any idea why the class is not found? Thank you in advance.

Upvotes: 1

Views: 236

Answers (1)

Ludwig Schulze
Ludwig Schulze

Reputation: 2315

The class path needs to contain the directory where your .class file lives. Not the .class file itself.

Upvotes: 1

Related Questions