Unable to read xml file when using exe4j to package jar into exe

75 views Asked by At

Recently I encountered a problem when using exe4j to package the jar into exe. My xml configuration file is placed in the same directory of the exe, but after the package is completed, the exe will look for the xml file from the temporary folder. These are the instructions in the exe4j help documentation

For some applications (especially GUI applications) you might want to change >the working directory to a specific directory relative to the executable, for >example to read config files that are in a fixed location. To do so, please >select the Change working directory to: checkbox and enter a directory relative >to the executable in the adjacent text field. To change the current directory >to the same directory where the executable is located, please enter a single >dot.

The error when i running the exe :

[ERROR] In Log's init,cann't read config file, file=/C:/Users/**/AppData/Local/Temp/e4jEA8.tmp_dir1543543191//sys_log.xml

Why is the program not looking for this xml from the exe's sibling directory, and how can I find it from this directory?

1

There are 1 answers

0
Ingo Kegel On

If you are using the "JAR in EXE" mode, use

System.getPrpoerty("install4j.exeDir")

to get the parent directory of the executable.