close

[Solved] The package java.awt is not accessible

Hello Guys, How are you all? Hope You all Are Fine. Today I am trying to import java.awt But I am facing following error The package java.awt is not accessible in Java. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

How The package java.awt is not accessible Error Occurs ?

I am trying to import java.awt But I am facing following error.

The package java.awt is not accessible

How To Solve The package java.awt is not accessible Error ?

  1. How To Solve The package java.awt is not accessible Error ?

    To Solve The package java.awt is not accessible Error You just need to add Libraries in this ways. First of all Go To Project.Select Properties.Then Select Libraries.Tap on  Add Library -> Execution Environment.Select the drop down list and then choose javaSE-1.7.Now, Your error must be solved. Second solution is First of all find module-info.java file and add following line in module-info.java. requires java.desktop; Now, your error must be solve now.

  2. The package java.awt is not accessible

    To Solve The package java.awt is not accessible Error You just need to add Libraries in this ways. First of all Go To Project.Select Properties.Then Select Libraries.Tap on  Add Library -> Execution Environment.Select the drop down list and then choose javaSE-1.7.Now, Your error must be solved. Second solution is First of all find module-info.java file and add following line in module-info.java. requires java.desktop; Now, your error must be solve now.

Solution 1: add Librarie

You just need to add Libraries in this ways.

  1. First of all Go To Project.
  2. Select Properties.
  3. Then Select Libraries.
  4. Tap on  Add Library -> Execution Environment.
  5. Select the drop down list and then choose javaSE-1.7.
  6. Now, Your error must be solved.

Solution 2: add requires java.desktop; to module-info.java

First of all find module-info.java file and add following line in module-info.java.

module test{
   requires java.desktop;
}

Now, your error must be solve now.

Summary

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you?

Also, Read

3 thoughts on “[Solved] The package java.awt is not accessible”

Leave a Comment