Hello everyone
I have this code and whenever i run it i get this error message. I tried to fix it but i dont know what is wrong with it.
HTML Code:
package D;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class D extends JFrame implements ActionListener {
JButton Exit, Name;
String fn,ln;
public D() {
this.setSize(400,300);
this.setTitle("Celsius and Fahrenheit conversion");
this.setVisible(true);
this.setLocationRelativeTo(null);
this.setLayout(new FlowLayout());
Container content = getContentPane();
Exit = new JButton("Close Program");
Exit.setActionCommand("Exit");
Name = new JButton("Enter Name");
Name.setActionCommand("Name");
Exit.addActionListener(this);
Name.addActionListener(this);
content.add(Exit, BorderLayout.NORTH);
content.add(Name, BorderLayout.WEST);
}
public void Actions(ActionEvent Action) {
if(Action.getActionCommand().contains("Exit")) {
System.exit(0);
}
if(Action.getActionCommand().equals("Name")) {
fn = JOptionPane.showInputDialog("Enter First Name: ");
ln = JOptionPane.showInputDialog("Enter Last Name: ");
JOptionPane.showMessageDialog(null, "Hello " + fn + " " + ln);
}
}
public static void main(String[] args) {
D();
}
}
Error Message:-
HTML Code:
run:
java.lang.NoClassDefFoundError: d/D (wrong name: D/D)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:791)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:472)
Exception in thread "main" Java Result: 1
BUILD SUCCESSFUL (total time: 1 second)