嗨,我有一个java代码,在netbeans中运行得很好,但当我想在eclipse中运行时,会出现这个异常
Exception in thread "main" class com.aspose.ocr.internal.g: Culture Name: en-US-EN is not a supported culture
com.aspose.ocr.internal.aP.b(Unknown Source)
com.aspose.ocr.internal.aP.<init>(Unknown Source)
com.aspose.ocr.internal.aP.a(Unknown Source)
com.aspose.ocr.internal.dj.b(Unknown Source)
com.aspose.ocr.internal.aP.c(Unknown Source)
com.aspose.ocr.internal.cG.c(Unknown Source)
com.aspose.ocr.z.<init>(Unknown Source)
com.aspose.ocr.ImageStream.fromFile(Unknown Source)
I.main(I.java:33)
at com.aspose.ocr.internal.aP.b(Unknown Source)
at com.aspose.ocr.internal.aP.<init>(Unknown Source)
at com.aspose.ocr.internal.aP.a(Unknown Source)
at com.aspose.ocr.internal.dj.b(Unknown Source)
at com.aspose.ocr.internal.aP.c(Unknown Source)
at com.aspose.ocr.internal.cG.c(Unknown Source)
at com.aspose.ocr.z.<init>(Unknown Source)
at com.aspose.ocr.ImageStream.fromFile(Unknown Source)
at I.main(I.java:33)
这是mi代码
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import com.aspose.ocr.ILanguage;
import com.aspose.ocr.ImageStream;
import com.aspose.ocr.Language;
import com.aspose.ocr.OcrEngine;
public class I {
public static void main(String[] args) {
// Set the paths
String imagePath = "samples/Sample.bmp";
String resourcesFolderPath = "../resources/resource.zip";
// Create an instance of OcrEngine
OcrEngine ocr = new OcrEngine();
// Set Resources for OcrEngine
try {
ocr.setResource(new FileInputStream(resourcesFolderPath));
} catch (FileNotFoundException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
// Set NeedRotationCorrection property to false
// ocr.getConfig().setNeedRotationCorrection(false);
// Set image file
ocr.setImage(ImageStream.fromFile(imagePath));
// Add language
ILanguage language = Language.load("spanish");
ocr.getLanguages().addLanguage(language);
// Perform OCR and get extracted text
try {
if (ocr.process()) {
System.out.println("ranswer -> " + ocr.getText());
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
我的ecplise版本是Luna Release(4.4.0)和netbeans 8
提前感谢您的时间并回答
Aspose有一些错误,它为不在其支持的硬编码列表中的"文化"(普通人称为"地区")抛出异常。
不知怎么的,我猜在Eclipse下运行时,您的区域设置字符串是"en-US en",但在NetBeans下运行时不是。
您可以尝试在命令行上传递user.language、user.conational、user.variant系统属性,以覆盖Eclipse在运行应用程序时设置的任何内容。
不过,免责声明:我自己不使用Eclipse。