Khiops Desktop doesn't print log in stderr in case of Java error
Description
When java is misconfigured, the java GUI is not launched and nothing is print in the console. The only way to get a log is by using the -e flag :
$ khiops -e error.log
$ cat error.log
error : Java : Unable to load libjvm.so (libjvm.so: cannot open shared object file: No such file or directory)lor check the LD_LIBRARY_PATH variable
error : Unable to load GUI, use -b and -i flags to launch khiops in batch mode (khiops -h for help)
It would be better to have this log directly in the stderr, the users would see the problem immediately.
Questions/Ideas
- It will be fixed by switching the
AddErrortoAddFatalErrorin the methodUIObject::GetJNIEnv().
Context
- Khiops version 10.2.0
- Linux
I faced this issue too. IMHO it would be better to catch the error case in the khiops-env shell script to give a feedback to the end-user
if [[ -n $JAVA_HOME ]]; then
KHIOPS_CLASSPATH=/usr/share/khiops/norm.jar:/usr/share/khiops/khiops.jar
KHIOPS_JAVA_PATH=$(find -L "$JAVA_HOME" -name libjvm.so | xargs dirname)
else
echo "We couldn't find your JVM installation. Please set the JAVA_HOME environment variable"
fi
My bad. As @popescu-v reminds me the postinst script of the khiops package updates now well the khiops-env script file : it sets automatically the JAVA_HOME or shows a warning to the end user.
May be one error case left then (that can lead to the error @bruno-at-orange refers to) : the path set in JAVA_HOME is no longer valid for whatever reason (desinstallation of the JVM or upgrade to a newer version).
if JAVA_HOME is no longer valid, khiops prints an error. No need to catch it in the khiops-env script, but of course the user have to see it.
When using directly the MODL binary, the error is printed in the console. The problem comes from the khiops bash script:
if [[ $# -eq 0 ]]; then
# run without parameters
# run and save scenario and log files in directory KHIOPS_LAST_RUN_DIR
$KHIOPS_MPI_COMMAND MODL -o "${KHIOPS_LAST_RUN_DIR}"/scenario._kh -e "${KHIOPS_LAST_RUN_DIR}"/log.txt
else
# run with parameters
$KHIOPS_MPI_COMMAND MODL "$@"
fi
when we launch khiops without parameter, the script add -e and -o, and then the error is printed in the default error file.