twain4java icon indicating copy to clipboard operation
twain4java copied to clipboard

Hello, Not work in Win11

Open nameHui opened this issue 8 months ago • 2 comments

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)

nameHui avatar Apr 22 '25 04:04 nameHui