0

I'm doing a small program for school and i'm writing the first part and I run it in NetBeans and everything works fine, but when I submit it for grading I get this error:

Exception in thread "main" java.lang.NoClassDefFoundError: TextMsgExpander (wrong name: textmsgexpander/Te

being a newbie in Java i'm not quite sure what this means. any guidance would be helpful Thanks in advance

package textmsgexpander;

/**
 *
 * @author Craig
 */
import java.util.Scanner;

public class TextMsgExpander {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        Scanner scnr = new Scanner(System.in);
        String userEntry = "";
        String userOutput = "";

        System.out.print("Enter Text: ");
        userEntry = scnr.nextLine();

       userOutput = "You entered: " + userEntry;
        System.out.println(userOutput);


        return;

        }

    }
Craig Jacobs
  • 13
  • 1
  • 3
  • How do you submit the code for grading? the classpath may be related, the code may need to be submitted without a package, and using the default package; possible duplicate of [NoClassDefFoundError: wrong name](http://stackoverflow.com/questions/7509295/noclassdeffounderror-wrong-name) – chickity china chinese chicken Mar 26 '17 at 19:16
  • We take the .java file and submit it to blackboard where it complies and then tells you if it's correct or not. here are the instructions Instructions Deliverables TextMsgExpander.java We will expect the above file(s) to be submitted Compile command javac TextMsgExpander.java -Werror We will use this command to compile your code – Craig Jacobs Mar 26 '17 at 19:28
  • Are there any instructions in the assignment to add the java `class` to a `package`? If no mention of that, try commenting-out (remove) the first line `package textmsgexpander;` and resubmit. – chickity china chinese chicken Mar 26 '17 at 19:30
  • Here check THIS-: http://stackoverflow.com/questions/7509295/noclassdeffounderror-wrong-name – Tushar Sharma Mar 26 '17 at 19:33
  • Possible duplicate of [Why am I getting a NoClassDefFoundError in Java?](http://stackoverflow.com/questions/34413/why-am-i-getting-a-noclassdeffounderror-in-java) – Shaishav Jogani Mar 26 '17 at 22:09

2 Answers2

1

Do you need to submit the whole folder or only the .java file? If the latter, then your problem might be that you define a package, but then submit only the java file.

Try deleting the first line ("package textmsgexpander;") and try again.

Hope this helps

krikki13
  • 46
  • 5
0

You should change this userEntry = scnr.nextLine(); to userEntry = scnr.next();This should work

XY-JOE
  • 1,574
  • 1
  • 11
  • 9
  • Also check if the package name `package textmsgexpander;` exist in the src folder. If not, delete that – XY-JOE Mar 26 '17 at 19:45