Hello, Not work in Win11
in win10 it's work . in win 11 , this line TwainIdentity id = (TwainIdentity) ids.next() error; why we can cast java.util.concurrent.Semaphore to free.lucifer.jtwain.TwainIdentity how to fiexd this question, can you provide some suggestions,thanks
public String[] getDeviceNames() throws TwainException {
List<TwainIdentity> identities = new ArrayList<>();
Twain.getIdentities(this, identities);
String[] names = new String[identities.size()];
Iterator<TwainIdentity> ids = identities.iterator();
for (int i = 0; ids.hasNext(); i++) {
TwainIdentity id = (TwainIdentity) ids.next();
names[i] = id.getProductName();
}
return names;
}
Unhndled exception java.lang.ClassCastException: java.util.concurrent.Semaphore cannot be cast to free.lucifer.jtwain.TwainIdentity at free.lucifer.jtwain.TwainScanner.getDeviceNames(TwainScanner.java:64)
I am very sorry, but I have not tested the project for compatibility with Windows 11. I can only speculate that the function is not working on line 1212 of the Twain.java file; there might have been changes in the behavior of the WndProc DDE function:
I will be able to check this after returning from a long business trip, sometime around August. If you find a solution yourself, you can contribute to the project.
This code is supposed to execute, but there is no execution coming from WndProc.
List list = (List) obj;
Semaphore s = (Semaphore) list.get(0);
list.remove(0);
sourceManager.getIdentities(list);
s.release();
break;
If this helps, you might want to check the incoming events in the TwainWndProc.java class and their parameters.
Thank you for your reply. The issue has been resolved through other issue