Eclipse doesn't find javax.swing

前端 未结 3 540
挽巷
挽巷 2020-12-20 17:20

Eclipse cant find the import javax.swing.JOptionPane

Where is it located and how can i include it?

import javax.swing.JOptionPane;


        
相关标签:
3条回答
  • 2020-12-20 17:48

    Try to Update the execution environment under system library to JavaSE-1.7 or JavaSE-1.8 in eclipse. To update the step below can be followed:

    > Right-click on the project
    > Select properties
    > Java build path
    > Library > Add Library > Add JRE SYSTEM Library
    > Execution Environment
    > Select JavaSE-1.7 or JavaSE-1.8
    > Finish
    
    0 讨论(0)
  • 2020-12-20 17:56
    1. There must be an installed (and selected) JDK in Eclipse:

      Window > Preferences > Java > Installed JREs   
      
    2. The project must be configured to use that JDK:

      Project > Properties > Java Build Path > Libraries
      

      there should be an entry like "JRE System Library [JDK7]" in the list. If not press:

      Add Library... > JRE System Library
      
    3. The project should have been created as a "Java Project":

      Project > Properties > Builders
      

      should include "Java Builder"

    0 讨论(0)
  • 2020-12-20 18:02

    The accepted answer did not work for me.

    This is how I solved it:

    Right-Click on your project, select Properties

    Go to Java Build Path

    Click Libraries, then Add Library ...

    Select JRE System Library

    Click on Execution environment and select JavaSE-1.7 or JavaSE-1.8

    Click Finish, then Apply and Close.

    0 讨论(0)
提交回复
热议问题