XK0-005 · Question #383
XK0-005 Question #383: Real Exam Question with Answer & Explanation
The correct answer is D: Set JAVA_HOME -which java. The Java application is failing because the JAVA_HOME environment variable is not set, even though Java itself is installed.
Question
A Linux administrator is running a script that runs a Java application but receives the following error: Error: Java_Home is not set Java is installed on the Linux server and java -version returns a value. Which of the following should the administrator add to the script to resolve this issue?
Options
- AExport PATH-$PATH: $JAVA_HOME
- BEcho `which java > $JAVA_HOME
- CExport Java_Home which java
- DSet JAVA_HOME -which java
Explanation
The Java application is failing because the JAVA_HOME environment variable is not set, even though Java itself is installed.
Common mistakes.
- A. This option attempts to modify the
PATHvariable using incorrect syntax, not to setJAVA_HOME. - B. This option uses
echoand redirection, which is not the correct command or syntax for setting an environment variable. - C. This option has incorrect syntax for
export, as it attempts to exportJava_Homewithout an assigned value and then executeswhich javaseparately.
Concept tested. Setting environment variables in Linux scripts
Reference. https://docs.oracle.com/en/java/javase/17/install/installation-jdk-linux-platforms.html
Topics
Community Discussion
No community discussion yet for this question.