Java Classpath Broken
I recently did a full upgrade pacman -Syyu & now I can't pass a classpath value to my Java virtual machine:
$ java -cp ./:./libs/*:./build/build_server:./build/build_server_maps:./build/build_server_script:./build/build_server_xmlconf games.stendhal.server.StendhalServer
Error: Could not find or load main class games.stendhal.server.StendhalServer
Caused by: java.lang.ClassNotFoundException: games.stendhal.server.StendhalServer
It was working the last time that I had run the command a couple days ago, before I did the update today. Note that it had probably been months since I did a system upgrade last.
Running the same command in a Windows Command Prompt does work:
>java -cp .\;libs\*;build\build_server;build\build_server_maps;build\build_server_script;build\build_server_xmlconf games.stendhal.server.StendhalServer
So it appears to be an issue with the MSYS2 console & parsing classpath string. I have not attempted a clean install yet.
Just tried with a fresh install & the problem is the same.
I can not suggest any proper solution but I have seen in many projects that a batch file is used to set the classpath. For example, I run batch scripts from jadx, ghidra etc. ~in msys2.~
Could you enclose the -cpargument in "$(cygpath -wp ...)" to see whether this fixes the issue?
Could you enclose the
-cpargument in"$(cygpath -wp ...)"to see whether this fixes the issue?
@dscho This does indeed fix it.
Is there something I can configure to force it to use cygpath -wp by default? (other than putting it in a script)
Is there something I can configure to force it to use
cygpath -wpby default? (other than putting it in a script)
That would be detrimental.
The idea of MSYS2's path conversion is to guess how to handle command-line arguments passed between MSYS and non-MSYS programs. Since this is an ambiguous task, the heuristic is necessarily wrong at times. In your case, I think that the heuristic would have been correct if the second path element had been an absolute path.
The idea of MSYS2's path conversion is to guess how to handle command-line arguments passed between MSYS and non-MSYS programs...
Something must have changed with a recent update because it used to parse the classpath parameter correctly without the need to enclose it in a call to cygpath.
@AntumDeluge commented 1 hour ago:
The idea of MSYS2's path conversion is to guess how to handle command-line arguments passed between MSYS and non-MSYS programs...
Something must have changed with a recent update because it used to parse the classpath parameter correctly without the need to enclose it in a call to
cygpath.
It would be nice if JRE for Windows would be taught to understand both Windows and *nix path formats. That would eliminate the need to use guessing.
@AntumDeluge, in the meantime you could use some java.exe wrapper script put into your PATH (somewhere before the original binary) which could do the conversion itself... Just a thought.
in the meantime you could use some
java.exewrapper script put into yourPATH(somewhere before the original binary) which could do the conversion itself... Just a thought.
Yes, that sounds like a good solution. I said before that I didn't want to put it in a script [that was dedicated to a single command]. But that was nonsense, because putting it in a universal wrapper will do exactly what I want.