Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Java Classpath Broken #207

Open
AntumDeluge opened this issue Mar 5, 2024 · 8 comments
Open

Java Classpath Broken #207

AntumDeluge opened this issue Mar 5, 2024 · 8 comments

Comments

@AntumDeluge
Copy link

AntumDeluge commented Mar 5, 2024

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.

@AntumDeluge
Copy link
Author

Just tried with a fresh install & the problem is the same.

@Biswa96
Copy link
Member

Biswa96 commented Mar 5, 2024

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.

@dscho
Copy link
Collaborator

dscho commented Mar 6, 2024

Could you enclose the -cpargument in "$(cygpath -wp ...)" to see whether this fixes the issue?

@AntumDeluge
Copy link
Author

AntumDeluge commented Mar 6, 2024

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)

@dscho
Copy link
Collaborator

dscho commented Mar 9, 2024

Is there something I can configure to force it to use cygpath -wp by 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.

@AntumDeluge
Copy link
Author

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.

@sskras
Copy link

sskras commented Mar 13, 2024

@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.

@AntumDeluge
Copy link
Author

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.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants