我正在尝试使用google-diff-match-patch,在运行以下代码时在diff_match_patch $ Diff上获取NoClassDefFoundError。
import name.fraser.neil.plaintext.diff_match_patch.Diff;
import name.fraser.neil.plaintext.diff_match_patch.LinesToCharsResult;
import name.fraser.neil.plaintext.diff_match_patch.Patch;
...
public static void difftest(){
String string1 = "My first string";
String string2 = "My second string";
diff_match_patch dmp = new diff_match_patch();
LinkedList<Diff> diffs= dmp.diff_main(string1, string2);
String html = dmp.diff_prettyHtml( diffs);
System.out.println(html);
}
我看过编译后的diff_match_patch.class和diff_match_patch $ Diff,diff_match_patch $ Patch和diff_match_patch $ LinesToCharsResult都在那里。我对静态嵌套类没有太多运气,但我认为这就是问题所在。
答案 0 :(得分:1)
我使用Makefile来构造我正在使用的jar,我需要在jar中包含嵌套类
CLASSES = $(SRCS:.java=.class) \
diff_match_patch$$Diff.class \
diff_match_patch$$Patch.class \
diff_match_patch$$LinesToCharsResult.class \
diff_match_patch$$Operation.class \
diff_match_patch$$1.class