While the same code working in NetBeans IDE It gives this error on eclipse ! I'm getting this error after running the code and giving the input
Exception in thread "main" java.lang.NoClassDefFoundError: net/sourceforge/jFuzzyLogic/FIS at pkt.Resturant.(Resturant.java:17) at pkt.Program.main(Program.java:15) Caused by: java.lang.ClassNotFoundException: net.sourceforge.jFuzzyLogic.FIS at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581) at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521) ... 2 more
Resturant.java file
package pkt;
import java.io.File;
import java.net.URISyntaxException;
import net.sourceforge.jFuzzyLogic.FIS;
public class Resturant {
private FIS fis;
private double servis;
private double yemek;
public Resturant(double servis, double yemek) throws URISyntaxException {
this.servis = servis;
this.yemek = yemek;
File dosya = new File(getClass().getResource("Model.fcl").toURI());
fis = FIS.load(dosya.getPath(), true);
fis.setVariable("servis", servis);
fis.setVariable("yemek", yemek);
fis.evaluate();
}
public Resturant() throws URISyntaxException {
File dosya = new File(getClass().getResource("Model.fcl").toURI());
fis = FIS.load(dosya.getPath(), true);
}
public FIS getModel() {
return fis;
}
@Override
public String toString() {
String cikti = "servis: " + servis + "\nYemek: " + yemek + "\nTur: " + fis.getVariable("tur").getValue();
return cikti;
}
}
Program.java file
package pkt;
import java.net.URISyntaxException;
import java.util.Scanner;
import net.sourceforge.jFuzzyLogic.plot.JFuzzyChart;
public class Program {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.print("Servis (0-9): ");
double servis = in.nextDouble();
System.out.print("Yemek (0-9): ");
double yemek = in.nextDouble();
try {
Resturant r = new Resturant(servis,yemek);
System.out.print(r);
} catch(URISyntaxException e) {
e.printStackTrace();
}
}
}
And the JFuzzyLogic file Model.fcl
FUNCTION_BLOCK model
VAR_INPUT
servis : REAL;
yemek : REAL;
END_VAR
VAR_OUTPUT
tur : REAL;
END_VAR
FUZZIFY servis
TERM kotu := (0,1)(4,0);
TERM iyi := (1,0)(4,1)(6,1)(9,0);
TERM mukemmel := (6,0)(9,1);
END_FUZZIFY
FUZZIFY yemek
TERM kotu := (0,1)(3,1)(6,0);
TERM lezzetli := (4,0)(9,1);
END_FUZZIFY
DEFUZZIFY tur
TERM ucuz := (0,1)(20,1)(50,0);
TERM orta := (40,0)(60,1)(80,0);
TERM iyi := (70,0)(85,1)(100,0);
METHOD : COG;
DEFAULT := 0;
END_DEFUZZIFY
RULEBLOCK kuralblock1
AND : MIN;
ACT : MIN;
ACCU : MAX;
RULE 1 : IF servis IS kotu OR yemek IS kotu THEN tur IS ucuz;
RULE 2 : IF servis IS iyi THEN tur IS orta;
RULE 3 : IF servis IS mukemmel AND yemek IS lezzetli THEN tur IS iyi;
END_RULEBLOCK
END_FUNCTION_BLOCK
All I can do at this point is point out the information you haven't provided, which would tell us what the problem is. Your project has source code, like the class "Restaurant", but it also has dependencies, like class "net.sourceforge.jFuzzyLogic.FIS". The latter class is not included in your project, it has to be specified as a dependency. There are several ways that Eclipse projects can specify dependencies, and they have to be done carefully.
We don't know how you have specified the dependency on that class "net.sourceforge.jFuzzyLogic.FIS", or even if you have at all. You could be using Maven to build your project, which would imply that you're using the "m2e" Eclipse plugin. You could also be using Ant, although I doubt it. You could also be using no build system at all, which means you must have intended to store the jar file containing that class directly in a subdirectory of your project, and specified a direct dependency on that jar.
We also don't know how you're running the project. It's most likely that you're running it directly in Eclipse, but I could be wrong.
I figured out what the problem is, It's the way of adding the FazzyLogic library! Instead of adding it to the Classpath I added it to the Modulepath! I've no experience with java neither eclipse IDE.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.