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

Explanation:

The error message you encountered, “target is not a JDK root. System library was not found,” typically occurs when you are trying to compile or run Java code using an incompatible or missing JDK (Java Development Kit) configuration.

To resolve this issue, you need to ensure that you have a valid JDK setup and configure your project or development environment accordingly. Here are some steps to help you with the configuration:

  1. Check if JDK is installed: Verify if you have JDK installed on your system. You can do this by opening a command prompt or terminal and running the following command: javac -version. If it displays the version information, JDK is installed. Otherwise, you need to download and install the latest JDK from the official Oracle website.
  2. Set JDK as environment variable: Once JDK is installed, you need to set it as an environment variable. This step is necessary for your system to recognize the JDK installation. The steps to set environment variables may differ based on your operating system. Here’s an example for Windows:

    • Right-click on “My Computer” or “This PC” and select “Properties”.
    • Click on “Advanced system settings” or “Advanced” tab.
    • Click on “Environment Variables” button.
    • Under “System Variables” section, click “New”.
    • Set the variable name as “JAVA_HOME”.
    • Set the variable value as the path to your JDK installation directory. For example, “C:\Program Files\Java\jdk1.8.0_291”.
    • Click “OK” to save the changes.

    Similar steps can be followed for other operating systems like macOS or Linux with slight variations.

  3. Configure IDE or project settings: If you are using an Integrated Development Environment (IDE) like Eclipse, IntelliJ, or NetBeans, you need to ensure that the IDE is using the correct JDK configuration. Open the IDE settings/preferences, navigate to the JDK settings, and select the appropriate JDK installation directory. Save the changes and restart the IDE if required.

    If you are working with a project using build tools like Maven or Gradle, make sure to update the project configuration files (pom.xml for Maven or build.gradle for Gradle) to specify the JDK version and location.
  4. Verify JDK configuration: After completing the above steps, verify if the JDK configuration is correctly set. Open a command prompt or terminal and run the following command: java -version. It should display the Java version information without any errors. If it shows the correct version, the JDK configuration is successful.

Once you have correctly set up the JDK configuration, you should no longer encounter the “target is not a JDK root. System library was not found” error. Remember to double-check your configuration settings if the error persists.

Example:

Let’s say you installed JDK version 1.8.0_291 in the default location on a Windows machine. The JAVA_HOME environment variable should be set as follows:

    
      Set the variable name as "JAVA_HOME".
      Set the variable value as "C:\Program Files\Java\jdk1.8.0_291".
    
  

Read more

Leave a comment