Java app expects files from $out/opt, so can't run wraper from $out/bin, only if cd into $out/opt and run wrapper from that. How to proceed?

I’m packaging this Java/Ant app Built files go into $out/opt, with a java wrapper created in $out/bin. However, the app has files in $out/opt which it expects to run some non-jar files (seemingly XML files) in $out/opt so that it runs. So running the wrapper in bin errors. It only works if I put the wrapper in opt, cd into that directory, and run from that directory, i.e. Java package guidelines - ArchWiki

Other files necessary to run the program are usually stored in the same folder as the main jar file, or a subdirectory thereof. Since Java programs do not know where their classes were loaded from, they usually need to be run from within this directory (i.e. the shell script should cd into the directory), or an environment variable is set to indicate the directory’s location.

How is this dealt with in nixpkgs? Is there an environment variable?

More info to reproduce the issue at com.osrmt.appclient.system.ConnectionXmlNotFoundException · Issue #59 · osrmt/osrmt · GitHub

Add --chdir to makeWrapper

    makeWrapper ${openjdk8}/bin/java $out/bin/osrmt \
      --chdir $out/opt \
      --prefix _JAVA_OPTIONS : "-Dawt.useSystemAAFontSettings=on" \
      --add-flags "-Duser.dir=$out/opt -classpath \"$classpath\" com.osrmt.appclient.reqmanager.RequirementManagerController"