ARTICLE AD BOX
A year ago I created an Eclipse project (Eclipse 2020-06, Java 8, Win 10) that uses the GIS LAStools libary to e.g. extract data from a couple of files.
I'm now using Win 11 on a different PC and want to work on the project again, so I copied the old project, installed the same Java version, the same Eclipse version (with the same settings, as far as I've seen) and the same library version.
My code:
Process p = null; ArrayList<String> lines = new ArrayList<String>(); String lasbinpath = "somepath\\LAStools\\bin"; String command = "lasindex64 -i someotherpath\\myfile.laz"; try { ProcessBuilder builder = new ProcessBuilder("cmd.exe", "/c", command); Map<String, String> env = builder.environment(); env.put("path", lasbinpath); builder.redirectErrorStream(true); p = builder.start(); BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream())); String line; while(true) { line = br.readLine(); if (line==null) { break; } lines.add(line); } br.close(); } catch(IOException e) { e.printStackTrace(); } finally { if(p!=null) { p.destroy(); } }When I try to run it, there's always the same error:
The "DOSKEY" command is either misspelled or could not be found.At first I thought that it might be the library's fault and started a question in the GIS stackexchange.
Yesterday I started up the old Win 10 PC again and the same code is still working fine there, even with the latest version of the library.
On Win 11 the same error appears when I run the code in Eclipse 2025-09 with OpenJDK 24 (even when run as admin) but there's no error when I run the library's command directly in command prompt. The "doskey.exe" file does exist in the "System32" folder and while the "Windows" and "System32" folders are protected, of course, I can manually access them without any problems. Other (native) commands like java -version and dir work fine with my code.
If I remove env.put("path", lasbinpath) and manually add the path to PATH instead, there's no more error and the code is working as expected.
I know that Win 11 can be weird about permissions and I've had problems with those before (app that was working fine on Win 10 can't access files in Win 11, unless run as admin), so I think that this is the case here too.
There are a couple of google search results about things not working as expected on Win 11, compared to Win 10 (not just with Java) but nothing about the ProcessBuilder. Is there a specific way I have to set up Eclipse and/or ProcessBuilder to give them access and work with a temporary PATH?
