0

I'm using NetBeans 6.9.1 on windows and i am following along with a rather simple java tutorial, first it asks me to use notepad but i'd rather just use a IDE for this, anyways i'm asked to create a file and put this code down:

class HelloWorldApp {
    public static void main(String[ ] args) {
       System.out.println("Hello World!" );
    }
}

and i get a lot of compiler errors:

java.lang.NoClassDefFoundError: javaapplication1/Main
Caused by: java.lang.ClassNotFoundException: javaapplication1.Main
    at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
Could not find the main class: javaapplication1.Main.  Program will exit.
Exception in thread "main" Java Result: 1

i tried to get the wizard to make as clean a starting project as possible, but it seems that nothing is simple here.

so is the code wrong, and the tutorial thus not worth following, or am i doing something wrong with the IDE?

1
  • Have you tried doing this with a simpler editor as the tutorial suggested? Perhaps Notepad or (my preference) Notepad++ which you can download for free? I'd suggest you try this first, and then later when you have Java working, go through the NetBeans tutorial (yes, there's a learning curve for this too), and learn to do it with NetBeans. Commented Nov 30, 2010 at 0:18

3 Answers 3

5

your compiler is looking for a Class called Main in a package called javaapplication1.

What you posted doesn't fit this at all.

Classes must be in a file with the name of the class.java.

Thus your class should be in a file called HelloWorldApp.java in the default package. From your stack trace this is not the case and appears to be in a file called Main.java in a package called javaaplication1

Sign up to request clarification or add additional context in comments.

Comments

0

Is it saying that it's trying to find a class named Main but you've named the class HelloWorldApp?

Is the HelloWorldApp in a file called HelloWorldApp.java?

Comments

0

Is your file named HelloWorldApp.java?

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.