Twain cannot load the plugged scanner after application start
up vote
0
down vote
favorite
I'm using the twain.jar to connect with Plustek SN8016U scanner.
Everything is working perfect if I plugged scanner before application running.
But if I start the application first with unplugged scanner device, after that I plugged scanner --> the exception is thrown by getDeviceNames method.
The below is demo code:
Scanner sc = Scanner.getDevice();
try {
sc.getDeviceNames();
} catch (Exception e) {
// Throw exception if I unplugged scanner before application running and plugged after
e.printStackTrace();
}
I debug the code, it seen the data (indentity) is cached after jtwain init.
I try to re init the jtwain, but no affected.
The below is library code that I think have a issue:
public String getDeviceNames() throws ScannerIOException {
Vector var1 = new Vector();
jtwain.getIdentities(this, var1);
String var2 = new String[var1.size()];
Enumeration var3 = var1.elements();
// TwainIdentity is cached hear. After I pluggin scanner, the vaule is not changed.
for(int var4 = 0; var3.hasMoreElements(); ++var4) {
TwainIdentity var5 = (TwainIdentity)var3.nextElement();
var2[var4] = var5.getProductName();
}
return var2;
}
I use mmscomputing library at hear: https://www.programcreek.com/java-api-examples/index.php?source_dir=Classeur-master/mmscomputing/uk/co/mmscomputing/device/twain/pdfapplet/TwainPdfAppletExample.java#
Any body give me a help. Thanks you.
java twain
add a comment |
up vote
0
down vote
favorite
I'm using the twain.jar to connect with Plustek SN8016U scanner.
Everything is working perfect if I plugged scanner before application running.
But if I start the application first with unplugged scanner device, after that I plugged scanner --> the exception is thrown by getDeviceNames method.
The below is demo code:
Scanner sc = Scanner.getDevice();
try {
sc.getDeviceNames();
} catch (Exception e) {
// Throw exception if I unplugged scanner before application running and plugged after
e.printStackTrace();
}
I debug the code, it seen the data (indentity) is cached after jtwain init.
I try to re init the jtwain, but no affected.
The below is library code that I think have a issue:
public String getDeviceNames() throws ScannerIOException {
Vector var1 = new Vector();
jtwain.getIdentities(this, var1);
String var2 = new String[var1.size()];
Enumeration var3 = var1.elements();
// TwainIdentity is cached hear. After I pluggin scanner, the vaule is not changed.
for(int var4 = 0; var3.hasMoreElements(); ++var4) {
TwainIdentity var5 = (TwainIdentity)var3.nextElement();
var2[var4] = var5.getProductName();
}
return var2;
}
I use mmscomputing library at hear: https://www.programcreek.com/java-api-examples/index.php?source_dir=Classeur-master/mmscomputing/uk/co/mmscomputing/device/twain/pdfapplet/TwainPdfAppletExample.java#
Any body give me a help. Thanks you.
java twain
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I'm using the twain.jar to connect with Plustek SN8016U scanner.
Everything is working perfect if I plugged scanner before application running.
But if I start the application first with unplugged scanner device, after that I plugged scanner --> the exception is thrown by getDeviceNames method.
The below is demo code:
Scanner sc = Scanner.getDevice();
try {
sc.getDeviceNames();
} catch (Exception e) {
// Throw exception if I unplugged scanner before application running and plugged after
e.printStackTrace();
}
I debug the code, it seen the data (indentity) is cached after jtwain init.
I try to re init the jtwain, but no affected.
The below is library code that I think have a issue:
public String getDeviceNames() throws ScannerIOException {
Vector var1 = new Vector();
jtwain.getIdentities(this, var1);
String var2 = new String[var1.size()];
Enumeration var3 = var1.elements();
// TwainIdentity is cached hear. After I pluggin scanner, the vaule is not changed.
for(int var4 = 0; var3.hasMoreElements(); ++var4) {
TwainIdentity var5 = (TwainIdentity)var3.nextElement();
var2[var4] = var5.getProductName();
}
return var2;
}
I use mmscomputing library at hear: https://www.programcreek.com/java-api-examples/index.php?source_dir=Classeur-master/mmscomputing/uk/co/mmscomputing/device/twain/pdfapplet/TwainPdfAppletExample.java#
Any body give me a help. Thanks you.
java twain
I'm using the twain.jar to connect with Plustek SN8016U scanner.
Everything is working perfect if I plugged scanner before application running.
But if I start the application first with unplugged scanner device, after that I plugged scanner --> the exception is thrown by getDeviceNames method.
The below is demo code:
Scanner sc = Scanner.getDevice();
try {
sc.getDeviceNames();
} catch (Exception e) {
// Throw exception if I unplugged scanner before application running and plugged after
e.printStackTrace();
}
I debug the code, it seen the data (indentity) is cached after jtwain init.
I try to re init the jtwain, but no affected.
The below is library code that I think have a issue:
public String getDeviceNames() throws ScannerIOException {
Vector var1 = new Vector();
jtwain.getIdentities(this, var1);
String var2 = new String[var1.size()];
Enumeration var3 = var1.elements();
// TwainIdentity is cached hear. After I pluggin scanner, the vaule is not changed.
for(int var4 = 0; var3.hasMoreElements(); ++var4) {
TwainIdentity var5 = (TwainIdentity)var3.nextElement();
var2[var4] = var5.getProductName();
}
return var2;
}
I use mmscomputing library at hear: https://www.programcreek.com/java-api-examples/index.php?source_dir=Classeur-master/mmscomputing/uk/co/mmscomputing/device/twain/pdfapplet/TwainPdfAppletExample.java#
Any body give me a help. Thanks you.
java twain
java twain
asked 19 hours ago
Cường Lư Quốc
1063
1063
add a comment |
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53237522%2ftwain-cannot-load-the-plugged-scanner-after-application-start%23new-answer', 'question_page');
}
);
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password