- #1
clook
- 35
- 0
Supposed to make a program that displays an entered name and date, etc, but it won't run.
I tried running it and eclipse said:
what's wrong? I thought I declared the class in the code.
Code:
import java.util.*;
import java.text.*;
import javax.swing.*;
public class ch2NameAndDate {
public static void main(String[] args) {
// Input the first, middle, and last name
// Display the name and the date.
String firstNameString, middleNameString, lastNameString;
//Create a Scanner object
Scanner inputScanner = new Scanner(System.in);
//Objects needed for date.
Date todayDate = new Date();
SimpleDateFormat formattingSimpleDateFormat=
new SimpleDateFormat("MMMM dd yyyy");
//Input the data
System.out.print("enter your First name ");
firstNameString = inputScanner.next();
//firstNameString = JOptionPane.showInputDialog("Enter your First Name");
//middleNameString enter middle name.
System.out.print("enter your Middle name ");
middleNameString = inputScanner.next();
//lastNameString = JOptionPane.showInputDialog("enter your Last name");
System.out.print("Enter your Last name ");
lastNameString = inputScanner.next();
//Print out first, middle, and last name with date.
System.out.println("Hello" + lastNameString + "," + " " + firstNameString + " " + str.substring(0); + "." + "today is " +
formattingSimpleDateFormat.format(todayDate));
}
}
I tried running it and eclipse said:
Code:
java.lang.NoClassDefFoundError: NameAndDate
Exception in thread "main"
what's wrong? I thought I declared the class in the code.