java swing component cannot be resolved

前端 未结 9 2020
灰色年华
灰色年华 2020-12-11 16:43

I took the following code from a tutorial:

import javax.swing.*;
import java.util.Date;

public class SwingGUI {

    public static void main( String[] args          


        
9条回答
  •  轮回少年
    2020-12-11 16:48

    The problem is not in code.

    It is due to JRE misconfiguration for project. It may be due to difference between the project's JRE and workspace's Jre.

    It may be solved by Updating Eclipse or Jre...

    But from my side, I recommend you to do so..

    Goto Window-->Preferences-->Java-->Installed JREs--->Execution Environments-->Select Project's JRE and tick the perfect matching installed JRE.

    If you have not a matching JRE download and add it in Installed JREs using Add Button.

    At last, RESTART your Eclipse IDE. This worked fine for me...

    If it does not work, UPDATE Eclipse..

提交回复
热议问题