0

I am creating a GUI on Eclipse using Java code. Everything in my code is fine except for some reason the java swing package is not being recognized by my IDE. I have used the correct imports and I am using JDK-17 which should include the swing package by default and yet the issue persists. I get the following error when I run my code: Exception in thread "main" java.lang.Error: Unresolved compilation problem: SwingUtilities cannot be resolved. It also mentions that the package in not accessible.

I'd appreciate any kind of help with this.

Here is my code Java Code. All of the imports are not accessible for some reason.

halemley
  • 3
  • 2
  • Have you added the JAR in class path ? – wolf Jul 26 '23 at 16:26
  • Does this answer your question? [Correct way to add external jars (lib/\*.jar) to an IntelliJ IDEA project](https://stackoverflow.com/questions/1051640/correct-way-to-add-external-jars-lib-jar-to-an-intellij-idea-project) – wolf Jul 26 '23 at 16:31
  • 1
    Do you have a `module-info.java` in the project? If you do you are using the Java 9 module system and need to update the module-info.java to require the java.desktop module - or just delete it to stop using the module system. – greg-449 Jul 26 '23 at 16:35
  • @greg-449 That did it! You are a life saver! Thank you & everyone so much! – halemley Jul 26 '23 at 16:50
  • If @greg-449 declines, you can [answer your own question](http://meta.stackoverflow.com/q/17463/163188). – trashgod Jul 26 '23 at 17:08

0 Answers0