我试图制作 c 中的 java 应用程序,源链接是http://phtranslator.sourceforge.net/我做了以下事情来调用那个 coe 但让它
public class Main {
/** Creates a new instance of Main */
public Main() {
}
public interface simpleDLL extends Library {
simpleDLL INSTANCE = (simpleDLL) Native.loadLibrary(
(Platform.isWindows() ? "C:\\translator\\PhTranslateLib.dll" : "simpleDLLLinuxPort"), simpleDLL.class);
public IntByReference GetTeluguTranslator();
public int Translate(IntByReference Translator, String szInput, StringBuilder szOutput, int nLen);
public int GetTranslatedBufferLength(IntByReference Translator, String szInput, Pointer out);
public void GetTranslatedBuffer(String szOutput, Pointer ppHint);
}
public static void main(String args[])
{
StringBuilder b =new StringBuilder();
simpleDLL sdll = simpleDLL.INSTANCE;
IntByReference y = sdll.GetTeluguTranslator();
int j= sdll.Translate( y , "ananathapura", b, 0);
System.out.println( b);
System.out.println(j);
}
}
I am getting Following `Exception`
Exception in thread "main" java.lang.IllegalArgumentException: Unsupported argument type java.lang.StringBuilder at parameter 2 of function Translate
at com.sun.jna.Function.convertArgument(Function.java:552)
at com.sun.jna.Function.invoke(Function.java:258)
at com.sun.jna.Library$Handler.invoke(Library.java:216)
at $Proxy0.Translate(Unknown Source)
at anil.test.Main.main(Main.java:71)
是String builder
用字符串替换我得到了成功,但没有存储在string