help in running helloapp program URGENT

this is my first java app

public class HelloApp

{

public static void main(String [] args)

{

System.out.println ("Hello Java, Hello World");

}

}

when i do : Java HelloApp

i get the error

exception in thread 'main' java.lang noclassdeffounderror: HelloApp

we tried doing java HelloApp.class and got the same error except w/ HelloApp/class

we did this command in the same folder that the '.class' file is located in

[495 byte] By [tovachanaha] at [2007-10-2 12:57:35]
# 1
Knock it off with this "urgent" bullsh*t and people might try to help you
tjacobs01a at 2007-7-13 10:14:57 > top of Java-index,Java Essentials,New To Java...
# 2
Don't mark your question as urgent. It is guaranteed NOT to get you help any faster than you otherwise would. The only affect it can have--if any--is to piss people off into not answering you.
jverda at 2007-7-13 10:14:57 > top of Java-index,Java Essentials,New To Java...
# 3

Put you code in the code tags like this -

public class HelloApp

{

public static void main(String [] args)

{

System.out.println ("Hello Java, Hello World");

}

}

It makes it less of pain in the *** to read. Did you compile the file before you tried to run it using -

javac HelloApp.java

Are you trying to run it from the directory that it is in?

colly10a at 2007-7-13 10:14:57 > top of Java-index,Java Essentials,New To Java...
# 4

If you follow the directions under the appropriate link for your OS exactly, it will work.

http://java.sun.com/docs/books/tutorial/getStarted/cupojava/index.html

To understand why you're having the problem you are...

[url=http://wiki.java.net/bin/view/Javapedia/ClassPath]Javapedia: Classpath[/url]

[url=http://java.sun.com/j2se/1.4.2/docs/tooldocs/windows/classpath.html]Setting the class path[/url] (Windows)

[url=http://java.sun.com/j2se/1.4.2/docs/tooldocs/findingclasses.html]How Classes are Found[/url]

java -cp .;<any other directories or jars> YourClassName

You get a NoClassDefFoundError message because the JVM (Java Virtual Machine) can't find your class. The way to remedy this is to ensure that your class is included in the classpath. The example assumes that you are in the same directory as the class you're trying to run.

javac -classpath .;<any additional jar files or directories> YourClassName.java

You get a "cannot resolve symbol" message because the compiler can't find your class. The way to remedy this is to ensure that your class is included in the classpath. The example assumes that you are in the same directory as the class you're trying to run.

jverda at 2007-7-13 10:14:57 > top of Java-index,Java Essentials,New To Java...
# 5
Thank you for the above links....it turns out the book we - a friend and I - are using, Java for Dummies, didn't mention that we had to change the 'classpath=' as well as the 'path=' we are into variables - local,static, and instance - now.i have bookmarked this
tovachanaha at 2007-7-13 10:14:57 > top of Java-index,Java Essentials,New To Java...
# 6
> it turns out the book we - a friend and I - are> using, Java for Dummies, didn't mention that we had> to change the 'classpath='...DON'T set the CLASSPATH environment variable. Do it the way mentioned earlier in this topic.
warnerjaa at 2007-7-13 10:14:57 > top of Java-index,Java Essentials,New To Java...
# 7
why it's working and in the link you gave me it said to do so
tovachanaha at 2007-7-13 10:14:57 > top of Java-index,Java Essentials,New To Java...
# 8

> why it's working and in the link you gave me it said

> to do so

jverd gave you some links, I didn't. Sure, some of those links might speak of setting a CLASSPATH variable as an option, but they likely also recommend against doing so, but rather explicitly passing the classpath via the command line.

java -cp (classpath here)

or

java -classpath (classpath here)

If you set a CLASSPATH (global environment variable), then you're making the assumption that ALL your java apps will share the same classpath, which is likely not the case unless you're just making a few 'toy' apps. In real life (where real java apps are run), no CLASSPATH environment variable is set nor relied upon.

warnerjaa at 2007-7-13 10:14:57 > top of Java-index,Java Essentials,New To Java...
# 9
I agree with warnerja.By posting what I did earlier, I was not intending to suggest useing a CLASPATH env var. Rather, I was just offering an explanation of how things work.I definitely consider it better practice to use the -cp or -classpath command-line options.
jverda at 2007-7-13 10:14:57 > top of Java-index,Java Essentials,New To Java...