Launching KoLmafia.jar with -DuseCWDasROOT not working on Linux

Not sure if this is a Java bug or a KoLmafia bug. In any case, KoLmafia on Linux, when launched with this option set, uses ~ (your home folder) as the "root". It's supposed to use the folder KoLmafia.jar is in, instead.
 

xKiv

Active member
It's supposed to use the folder KoLmafia.jar is in, instead.

Actually, it's supposed to use the current working directory. Which is probably the same directory if you don't know that you can run java -jar /path/to/somewhere/else/file.jar. But it's important to note this. CWD is much simpler to work out than "which directory houses the .jar" (one standard system call versus a long method chain that isn't guaranteed to work in all situations).
 

xKiv

Active member
UtilityConstants has the code for that, if you want to try troubleshooting it.

relevant code:
Code:
ROOT_LOCATION =	Boolean.getBoolean( "useCWDasROOT" ) ?		UtilityConstants.BASE_LOCATION : ...
which is
Code:
BASE_LOCATION = new File( System.getProperty( "user.dir" ) ).getAbsoluteFile();
That's CWD.

Note that
java specification said:
Boolean.getBoolean probably doesn't do what you think it does:
Returns true if and only if the system property named by the argument exists and is equal to the string "true".

You must use -DuseCWDasROOT=true. Using -DuseCWDasROOT is not enough (it is equivalent to setting the property to "false").
 
Top