因业务需要,需要调用DLL文件,参考网上的文件与方法,写了如下代码:
package com.fr.function;
import com.fr.script.AbstractFunction;
import com.sun.jna.Library;
import com.sun.jna.Native;
public class geth extends AbstractFunction {
public interface seuif97 extends Library { //cdecl call调用约定时为Library
seuif97 INSTANCE = (seuif97)Native.loadLibrary(System.getProperty("user.dir")+"/dll/SEUIF97.dll",seuif97.class);
public double seupt(double a,double b,int c);
}
public Object run(Object[] args) {
double S1=Double.parseDouble(args[0].toString());
double S2=Double.parseDouble(args[1].toString());
double h=seuif97.INSTANCE.seupt(S1,S2,4);
return h;
}
public static void main(String[] args) throws Exception {
Object s11=9.43;
Object s21=533.08;
double s1=Double.parseDouble(s11.toString());
double s2=Double.parseDouble(s21.toString());
try {
double h=seuif97.INSTANCE.seupt(s1,s2,4);
System.out.println(h);
}catch(Exception e){
System.out.println( e.getMessage());
}
}
}
最后提示:
java.lang.NoClassDefFoundError: Could not initialize class com.fr.function.seuif97
at com.fr.function.geth.run(geth.java:18)
at com.fr.script.AbstractFunction.tryRun(AbstractFunction.java)
at com.fr.script.AbstractFunction.evalExpression(AbstractFunction.java)
at com.fr.parser.FunctionCall.eval(FunctionCall.java)
at com.fr.script.Calculator.eval(Calculator.java)
at com.fr.stable.script.Expression.eval(Expression.java:35)
at com.fr.script.Calculator.evalString(Calculator.java)
at com.fr.script.Calculator.eval(Calculator.java)
at com.fr.script.Calculator.evalValue(Calculator.java)
at com.fr.stable.AbstractFormulaProvider.evalValue(AbstractFormulaProvider.java)
求怎么处理? |