Target is not a jdk root. system library was not found.

Query: “target is not a jdk root. system library was not found.”

This error message usually occurs when a Java Development Kit (JDK) is not correctly set up or configured on your machine. It indicates that the specified target directory is not recognized as a valid JDK root, and the system library required for Java development is missing.

To resolve this issue, you need to ensure that you have a JDK installed and properly configured on your system. Here are the steps to follow:

  1. Check JDK Installation: Verify that you have a JDK installed on your machine. You can do this by opening a terminal or command prompt and running the command java -version. If the command is not recognized or returns an error, it means you need to install a JDK.
  2. Download and Install JDK: Visit the official Oracle JDK website (https://www.oracle.com/java/technologies/javase-jdk11-downloads.html) to download the appropriate JDK version for your operating system. Follow the installation instructions for your platform.
  3. Set JDK Path: Once the JDK is installed, you need to set the JDK path as an environment variable. The exact steps to do this depend on your operating system:
    • Windows: Go to System Properties > Advanced > Environment Variables. Create a new system variable named “JAVA_HOME” and set its value to the JDK installation directory (e.g., C:\Program Files\Java\jdk1.8.0_271).
    • Linux: Open a terminal and edit the .bashrc or .bash_profile file in your home directory. Add the following line at the end of the file:
      export JAVA_HOME=/usr/lib/jvm/jdk1.8.0_271

      Change the path to match the JDK installation location on your system.

    • Mac OS: Open a terminal and edit the .bash_profile file in your home directory. Add the following line at the end of the file:
      export JAVA_HOME=$(/usr/libexec/java_home)
  4. Verify JDK Setup: Close and reopen any terminal or command prompt windows for the changes to take effect. Then run the java -version command again to verify that the JDK is now recognized.

After following these steps, the error message “target is not a jdk root. system library was not found” should no longer appear. You can now proceed with your Java development tasks without encountering this issue.

Example:

Let’s assume you are using Windows and have successfully installed JDK 11 in the default location (C:\Program Files\Java\jdk-11.0.11). To set the JDK path as a system variable:

  1. Open the Control Panel and go to System.
  2. Click on “Advanced system settings” on the left.
  3. In the System Properties window, click on the “Environment Variables” button.
  4. In the “System Variables” section, click on “New”.
  5. Enter “JAVA_HOME” as the variable name and “C:\Program Files\Java\jdk-11.0.11” as the variable value.
  6. Click “OK” to save the variable.

Now, when you run the command java -version in the command prompt, it should display the JDK version information instead of generating errors.

Same cateogry post

Leave a comment