XK0-005 · Question #383
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…
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
How the community answered
(31 responses)- A10% (3)
- B6% (2)
- C3% (1)
- D81% (25)
Why each option
The Java application is failing because the JAVA_HOME environment variable is not set, even though Java itself is installed.
This option attempts to modify the `PATH` variable using incorrect syntax, not to set `JAVA_HOME`.
This option uses `echo` and redirection, which is not the correct command or syntax for setting an environment variable.
This option has incorrect syntax for `export`, as it attempts to export `Java_Home` without an assigned value and then executes `which java` separately.
This option attempts to set the `JAVA_HOME` variable by referencing the `java` executable's location using `which java`, though the syntax `Set JAVA_HOME -which java` is an unconventional representation of standard shell commands like `export JAVA_HOME=$(which java)`.
Concept tested: Setting environment variables in Linux scripts
Source: https://docs.oracle.com/en/java/javase/17/install/installation-jdk-linux-platforms.html
Topics
Community Discussion
No community discussion yet for this question.