swing – java.lang.ClassNotFoundException doesnot go away even if all solutions tried

I’ve tried every solution provided in other similar questions. I’m a beginner, so I started by making a JFrame and all by using the NetBeans drag and drop thing and then copied all the java files to run in eclipse. My device was too weak to handle Netbeans so I used it as a 1-time thing. But now, even if no errors are shown before running, I keep running into the same. (completely new here. sorry for the inconvenience. And grateful for all the help) Error message: Error: Could not find or load main class LoginPage Caused by: java.lang.ClassNotFoundException: LoginPage

project>properties>java Build Path stuff –didnt work

Run config>JUnit-test –didnt work

public class LoginPage extends javax.swing.JFrame {

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JPanel ContPanel;
    private javax.swing.JButton LogIn;
    private javax.swing.JPanel MainPanel;
    private javax.swing.JLabel Password;
    private javax.swing.JPasswordField PasswordField;
    private javax.swing.JRadioButton RadioShowPass;
    private javax.swing.JButton Reset;
    private javax.swing.JLabel TitleLogIn;
    private javax.swing.JTextField User;
    private javax.swing.JTextField UserField;
   
    public LoginPage() {
        initComponents();
    }

    private void initComponents() {

        MainPanel = new javax.swing.JPanel();
        ContPanel = new javax.swing.JPanel();
        User = new javax.swing.JTextField();
        UserField = new javax.swing.JTextField();
        Password = new javax.swing.JLabel();
        PasswordField = new javax.swing.JPasswordField();
        RadioShowPass = new javax.swing.JRadioButton();
        LogIn = new javax.swing.JButton();
        Reset = new javax.swing.JButton();
        TitleLogIn = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Login Page");
        setBackground(new java.awt.Color(0, 0, 0));
        setUndecorated(true);
        setResizable(false);

        MainPanel.setBackground(new java.awt.Color(47, 60, 126));

        ContPanel.setBackground(new java.awt.Color(251, 234, 235));
        ContPanel.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        User.setEditable(false);
        User.setBackground(new java.awt.Color(251, 234, 235));
        User.setFont(new java.awt.Font("Segoe UI", 1, 12)); // NOI18N
        User.setText("User:");
        User.setAutoscrolls(false);
        User.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
        User.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
                UserActionPerformed(evt);
             }
        });

        UserField.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));

        Password.setFont(new java.awt.Font("Segoe UI", 1, 12));
        Password.setText("Password:");

        PasswordField.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));

        RadioShowPass.setFont(new java.awt.Font("Segoe UI", 0, 10));
        RadioShowPass.setText("Show Password");

        LogIn.setBackground(new java.awt.Color(238, 164, 127));
        LogIn.setText("Login");
        LogIn.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
        LogIn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                LogInActionPerformed(evt);
            }
        });

        Reset.setBackground(new java.awt.Color(204, 255, 255));
        Reset.setText("Reset");
        Reset.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
        Reset.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ResetActionPerformed(evt);
            }
        });

        TitleLogIn.setFont(new java.awt.Font("Segoe UI Black", 0, 18));
        TitleLogIn.setForeground(new java.awt.Color(86, 47, 126));
        TitleLogIn.setText("LOGIN");

        javax.swing.GroupLayout ContPanelLayout = new javax.swing.GroupLayout(ContPanel);
        ContPanel.setLayout(ContPanelLayout);
        ContPanelLayout.setHorizontalGroup(
            ContPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(ContPanelLayout.createSequentialGroup()
                .addGap(33, 33, 33)
                .addGroup(ContPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(Password)
                    .addComponent(User, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(ContPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(ContPanelLayout.createSequentialGroup()
                        .addComponent(RadioShowPass)
                        .addGap(152, 152, 152))
                    .addGroup(ContPanelLayout.createSequentialGroup()
                        .addGroup(ContPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, ContPanelLayout.createSequentialGroup()
                                .addComponent(Reset)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(LogIn))
                            .addComponent(PasswordField, javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(UserField, javax.swing.GroupLayout.Alignment.TRAILING))
                        .addGap(66, 66, 66))))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, ContPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(TitleLogIn)
                .addGap(138, 138, 138))
        );
        ContPanelLayout.setVerticalGroup(
            ContPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(ContPanelLayout.createSequentialGroup()
                .addGap(5, 5, 5)
                .addComponent(TitleLogIn)
                .addGap(18, 18, 18)
                .addGroup(ContPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(User, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(UserField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(ContPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(Password)
                    .addComponent(PasswordField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(RadioShowPass)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(ContPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(Reset)
                    .addComponent(LogIn))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout MainPanelLayout = new javax.swing.GroupLayout(MainPanel);
        MainPanel.setLayout(MainPanelLayout);
        MainPanelLayout.setHorizontalGroup(
            MainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(MainPanelLayout.createSequentialGroup()
                .addGap(98, 98, 98)
                .addComponent(ContPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(111, Short.MAX_VALUE))
        );
        MainPanelLayout.setVerticalGroup(
            MainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(MainPanelLayout.createSequentialGroup()
                .addGap(79, 79, 79)
                .addComponent(ContPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(88, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(MainPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(MainPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        pack();
    }
    
    private void ResetActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ResetActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_ResetActionPerformed

    private void LogInActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_LogInActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_LogInActionPerformed

    private void UserActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_UserActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_UserActionPerformed

    
    public static void main(String[] args) {

        LoginPage LoginPage=new LoginPage();
            LoginPage.setVisible(true); 
    }
}

Leave a Comment