I found an issue within the LoadLibs method extractTessResources(),
the file that is returned has the path shortened into an old dos style format (e.g. C:\Users\Forname.Surname\AppData\Local\Temp\tess4j\win64-x86-64 turns into C:\Users\FORNA~1.SUR\AppData\Local\Temp\tess4j\win64-x86-64)
this happens because System.getProperty("java.io.tmpdir") used in LoadLibs already returnes the "wrong" path. This seems to be because of a legacy dos setting in windows.
this causes issues when directly trying to access this file / folder. Now I have to build a workaround around it to make sure I get the realPath().
I was able to use
String tmpDir = System.getProperty("java.io.tmpdir"); //dos shortened path
Path tmpDirPath = Paths.get(tmpDir);//still dos shortened, but end slash removed
String fullPath = tmpDirPath.toRealPath().toString();//actual real path
maybe this is not the place for it, as it is a windows setting and legacy / backwards compatability problem. But it would be cool if LoadLibs ensures that the path is the realPath and also returns it for further use
other sources:
https://stackoverflow.com/questions/60400185/how-do-i-prevent-java-io-tmpdir-from-using-the-shortened-dos-style-filenames
https://helgeklein.com/blog/why-disabling-the-creation-of-83-dos-file-names-will-not-improve-performance-or-will-it/
Anonymous
I remember the 8.3 filename limitation in old DOS or Windows 95 era, but all modern OSes should be able to handle the long filenames.
Which Windows version are you seeing the issue in?
I'm using Win11 Pro (64 Bit).
On my Win11 machine,
java.io.tmpdiris resolved toC:\Users\<username>\AppData\Local\Temp\tess4j.You might have correctly assessed, this seems to be due to a legacy dos setting in windows on your machine. You might try setting the Windows Registry value as suggested in the second article you mentioned.
Last edit: Quan Nguyen 2023-04-18
Thanks for your support. I ended up not using the path returned by the method. I let tess4j do its thing and that works fine. If I ever end up needing the path, I'll ensure that my registry value works or that I do it another way