嗨,我正在使用java,我正在使用twain jar实现从扫描仪读取扫描的文档。我正在使用64位java和64位Windows 7.我在system32中添加了twain 64相关的dll。我得到这些例外
uk.co.mmscomputing.device.twain.TwainFailureException: Failed during call to twain source.
cc=No Data Source
rc=1
Source Manager Open
Source Manager Open
uk.co.mmscomputing.device.twain.TwainIOException: uk.co.mmscomputing.device.twain.TwainScanner.setException:
Failed during call to twain source.
cc=No Data Source
rc=1
at uk.co.mmscomputing.device.twain.TwainScanner.signalException(TwainScanner.java:131)
at uk.co.mmscomputing.device.twain.jtwain.signalException(jtwain.java:287)
at uk.co.mmscomputing.device.twain.jtwain.cbexecute(jtwain.java:243)
at uk.co.mmscomputing.device.twain.jtwain.nstart(Native Method)
at uk.co.mmscomputing.device.twain.jtwain.access$200(jtwain.java:12)
at uk.co.mmscomputing.device.twain.jtwain$1.run(jtwain.java:338)
uk.co.mmscomputing.device.twain.TwainFailureException: Failed during call to twain source.
cc=No Data Source
rc=1
at uk.co.mmscomputing.device.twain.TwainSourceManager.call(TwainSourceManager.java:27)
at uk.co.mmscomputing.device.twain.TwainIdentity.open(TwainIdentity.java:70)
at uk.co.mmscomputing.device.twain.TwainSource.open(TwainSource.java:99)
at uk.co.mmscomputing.device.twain.TwainSourceManager.openSource(TwainSourceManager.java:93)
at uk.co.mmscomputing.device.twain.jtwain.cbexecute(jtwain.java:234)
at uk.co.mmscomputing.device.twain.jtwain.nstart(Native Method)
at uk.co.mmscomputing.device.twain.jtwain.access$200(jtwain.java:12)
at uk.co.mmscomputing.device.twain.jtwain$1.run(jtwain.java:338)
public class TwainExample implements ScannerListener{
static TwainExample app;
Scanner scanner;
public TwainExample(String[] argv)throws ScannerIOException{
scanner=scanner.getDevice();
String scanners[]=scanner.getDeviceNames();
for(String scann:scanners){
System.out.println(scann);
}
scanner.addListener(this);
scanner.acquire();
}
public void update(ScannerIOMetadata.Type type, ScannerIOMetadata metadata){
if(type.equals(ScannerIOMetadata.ACQUIRED)){
BufferedImage image=metadata.getImage();
System.out.println("Have an image now!");
try{
ImageIO.write(image, "png", new File("mmsc_image.png"));
}catch(Exception e){
e.printStackTrace();
}
}else if(type.equals(ScannerIOMetadata.NEGOTIATE)){
ScannerDevice device=(ScannerDevice) metadata.getDevice();
try{
// device.setShowUserInterface(true);
// device.setShowProgressBar(true);
// device.setResolution(100);
}catch(Exception e){
e.printStackTrace();
}
}else if(type.equals(ScannerIOMetadata.STATECHANGE)){
System.err.println(metadata.getStateStr());
if(metadata.isFinished()){
System.exit(0);
}
}else if(type.equals(ScannerIOMetadata.EXCEPTION)){
metadata.getException().printStackTrace();
}
}
public static void main(String[] argv){
try{
app=new TwainExample(argv);
}catch(Exception e){
e.printStackTrace();
}
}
}
答案 0 :(得分:1)
您的计算机上可能没有64位TWAIN驱动程序。您可以下载并安装64-bit TWAIN sample data source,然后重试。
答案 1 :(得分:0)
我有类似的问题。解决方案是安装jdk java 32bit。