nerdexam
CompTIACompTIA

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.

Troubleshooting

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 PATH variable using incorrect syntax, not to set JAVA_HOME.
  • B. This option uses echo and 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 export Java_Home without an assigned value and then executes which java separately.

Concept tested. Setting environment variables in Linux scripts

Reference. https://docs.oracle.com/en/java/javase/17/install/installation-jdk-linux-platforms.html

Topics

#Environment Variables#Shell Scripting#Java Application Management#Linux Commands

Community Discussion

No community discussion yet for this question.

Full XK0-005 PracticeBrowse All XK0-005 Questions