I created an EXE with L4J 3.11.
It works as expected when I start via clicking in the Explorer.
But if I try to start the EXE from commandline, nothing happens.
If I switch to console head, I at least get error messages from Java that show that the commandline is wrong.
Using --l4j-debug
I found that the problem is the classpath.
My config XML has <classPath><cp>classpath-lib/*.jar</cp></classPath>
, which results at runtime first in Add classpath: classpath-lib\*.jar
, then in the launcher arg -classpath "
.
I didn't leave anything out and this is not two single quotes, but one double quote.
If I execute the EXE from Explorer I instead get Add classpath: classpath-lib\*.jar
, then " : classpath-lib\bridj-0.7.0.jar
and then the correct launcher arg -classpath "classpath-lib\bridj-0.7.0.jar"
.
So I guess somewhere in head.c
between lines 1040 and 1071 is a problem that causes 1071 not to be executed which would have added the closing quote at least.
I just wonder that it works from Explorer but not from the commandline, but I'm a bit at a loss to investigate further as I don't find L4J build instructions anywere to maybe add some more debugging.
After a bit IDA Pro disassembling and gdb debugging I think I found the two issues I had. The first was misconfiguration by me, the second probably a programming bug in
head.c
.The misconfiguration was that I used
<classPath><cp>classpath-lib/*.jar</cp></classPath>
and<jre><opt>--module-path</opt><opt>lib</opt></jre>
instead of<classPath><cp>%EXEDIR%/classpath-lib/*.jar</cp></classPath>
and<jre><opt>--module-path</opt><opt>%EXEDIR%/lib</opt></jre>
. This cause the directories to be searched for in the working directory, not in the EXE directory which made the difference between calling from Explorer and calling from commandline which I did not do in the directory where the EXE resides.This leads to the second error, the one in
head.c
. As the<classPath><cp/></classPath>
setting pointed to a wrong path, the_findfirst(cp, &c_file)
call inhead.c:1051
cannot find anything for the wildcard. The line1070
which is*(launcher.args + strlen(launcher.args) - 1) = 0;
should remove the last semicolon from the added classpath if I understand it correctly. The problem is, that if no paths were found, instead the opening double quote is removed which then results in only the closing double quote be present which then makes up the invalid command line.