Crescendo
Crescendo

Reputation: 105

Why doesn't Eclipse recognize import java.JOptionPane?

I'm on the Eclipse program for Java developers, and for some reason, Eclipse doesn't recognize import javax.swing.JOptionPane when creating a new class.

If you attempt to make a new class and have the code imported automatically, nothing pops up

Java Error

In fact, nothing remotely related to javax.swing pops up. Any ideas on what's going on? I removed the JRE system library and re-added it again. But that didn't work.

Upvotes: 2

Views: 8250

Answers (1)

Steampunkery
Steampunkery

Reputation: 3874

Here are some things that could be causing a problem:

  1. Make sure you have a JDK installed and selected in eclipse

    Window > Preferences > Java > Installed JREs
    
  2. Make sure it’s in your build path

    Project > Properties > Java Build Path > Libraries
    

    One of the Libraries should be something along the lines of “JRE System Library [JDK9]”. If there isn’t one, add it with:

    Add Library > JRE System Library
    
  3. Your project should be a Java project

    Project > Properties > Builders
    

Should have a “Java Builder” entry.

After doing all that, rebuild your project with Project > Clean then select your project. If none of that works, completely uninstall Java, reinstall the JDK and JRE then repeat steps 1-3. Source.

Upvotes: 1

Related Questions