New to Java - Having Trouble 'Java-***' .class files

I have learned how to 'javac' Files, and I am having trouble 'javaing' them. I have tried lots of things but it says:

Exception in thread"main" java.lang.NoClassDefFoundError: HelloWorldApp

Of course I am just learning so I am trying out the HelloWorldApp just to learn how to Compile and Run my Applications.

Help please!

[377 byte] By [Zacha] at [2007-11-26 17:49:43]
# 1
Hai Zachplz email me atravi.maxspeed@gmail.com
ScarletPimpernela at 2007-7-9 5:02:11 > top of Java-index,Java Essentials,New To Java...
# 2
I suppose the obvious question is... what input produces this response?
DavidKNa at 2007-7-9 5:02:11 > top of Java-index,Java Essentials,New To Java...
# 3
> I suppose the obvious question is... what input> produces this response?Oh, very sorry. Forgot to put that down. After creating the .class file I tried the 'java' function and that is the output I got.
Zacha at 2007-7-9 5:02:11 > top of Java-index,Java Essentials,New To Java...
# 4

Neverending story: http://forum.java.sun.com/thread.jspa?threadID=5134072&messageID=9485301

Zach, Zach, Zach... I think this "thread" is approaching 100 posts in total, and you still haven't been able to run your first program. Is there anyone out there who can sit down with you and show you how to do it? This really shouldn't take 100 posts!

DrLaszloJamfa at 2007-7-9 5:02:11 > top of Java-index,Java Essentials,New To Java...
# 5

> Neverending story:

> http://forum.java.sun.com/thread.jspa?threadID=5134072

> &messageID=9485301

>

> Zach, Zach, Zach... I think this "thread" is

> approaching 100 posts in total, and you still haven't

> been able to run your first program. Is there anyone

> out there who can sit down with you and show you how

> to do it? This really shouldn't take 100 posts!

I couldn't find my other Threads... And no, nobody in my family or anybody I know has ever been interested in programming. So, of course I need help with this.

Zacha at 2007-7-9 5:02:11 > top of Java-index,Java Essentials,New To Java...
# 6

Still not enough info, but lacking that, check the case of the class.

helloworldapp != HelloWorldApp

also, don't include the .class extension when you run java HelloWorldApp, and make sure the file name matches the class name

Class HelloWorldApp should be saved in the file HelloWorldApp.java

~Tim

SomeoneElsea at 2007-7-9 5:02:11 > top of Java-index,Java Essentials,New To Java...
# 7
> I couldn't find my other Threads...It's a good idea to use the watchlist. In your "Forum settings" you can set it to automatically add a thread you create to your watch list, or you could check the checkbox labelled "add topic to watch list" that is below the text area.
DrLaszloJamfa at 2007-7-9 5:02:11 > top of Java-index,Java Essentials,New To Java...
# 8

C:\>cd C:\Documents and Settings\Owner\My Documents\java

C:\Documents and Settings\Owner\My Documents\java>PATH="C:\Program Files\Java\jdk1.6.0\bin"

C:\Documents and Settings\Owner\My Documents\java>javac HelloWorldApp.java

C:\Documents and Settings\Owner\My Documents\java>java HelloWorldApp

Exception in thread "main" java.lang.NoClassDefFoundError: HelloWorldApp

That's what happened.

Zacha at 2007-7-9 5:02:11 > top of Java-index,Java Essentials,New To Java...
# 9

I told you yesterday as to how you should go about doing this.

When you want to run the code do this

java -classpath . filename

(assuming that you are in the same directory where your class file is)

Don't miss the . after the classpath.After you write classpath give a space then a dot and then again a space and then your class name.Is it done now.

qUesT_foR_knOwLeDgea at 2007-7-9 5:02:11 > top of Java-index,Java Essentials,New To Java...
# 10

C:\Testing\junk>notepad HelloWorldApp.java//Create the file

//Type this in verbatim

public class HelloWorldApp {

public static void main(String [] args){

System.out.println("Hello, Cruel World!");

}

}

//save the file and exit

C:\Testing\junk>javac HelloWorldApp.java#> type this line to compile

C:\Testing\junk>java HelloWorldApp#> type this line to run

Hello, Cruel World!

Done!

Good Bye,

~Tim

SomeoneElsea at 2007-7-9 5:02:11 > top of Java-index,Java Essentials,New To Java...
# 11
Jeepers Zach! I told you you'd never get it. Didn't believe me though, did you?
warnerjaa at 2007-7-9 5:02:11 > top of Java-index,Java Essentials,New To Java...
# 12

>

>

> C:\Testing\junk>notepad HelloWorldApp.java

>//Create the file

> pe this in verbatim

>

> public class HelloWorldApp {

>

> public static void main(String [] args){

> System.out.println("Hello, Cruel World!");

>

> }

>

> //save the file and exit

>

>

> C:\Testing\junk>javac HelloWorldApp.java

>#> type this line to compile

> HelloWorldApp#> type this line to run

>

> Hello, Cruel World!

>

>

>

> Done!

>

> Good Bye,

>

> ~Tim

I know what to type into the Prompt, I just don't know why it isn't working.

Also, warnerja, go away if you're not going to try to help.

Zacha at 2007-7-9 5:02:11 > top of Java-index,Java Essentials,New To Java...
# 13

I'm having this same error when I try to run my first .class file. I have set paths for my Windows XP environment variables, etc. I deleted any previous Runtime Environment versions on my computer that might interfere, now I can't even run applets on a webpage!Did you ever figure this out Zach?

rrunnera at 2007-7-9 5:02:11 > top of Java-index,Java Essentials,New To Java...
# 14
> Also, warnerja, go away if you're not going to try to help. You mean my trying to get you to understand you're in the wrong field of study is not helping? Ok then, keep up the frustration and wasting of your time.
warnerjaa at 2007-7-9 5:02:11 > top of Java-index,Java Essentials,New To Java...
# 15
I tried the suggestion in a previous post:java -classpath . HelloWorldAppIt worked! Hurray!Now, why do I have to type that every time? And how can I get my web browser to find the new Runtime Environment I just installed?
rrunnera at 2007-7-9 5:02:12 > top of Java-index,Java Essentials,New To Java...
# 16

> > C:\>cd C:\Documents and Settings\Owner\My

> Documents\java

> C:\Documents and Settings\Owner\My

> Documents\java>PATH="C:\Program

> Files\Java\jdk1.6.0\bin"

> C:\Documents and Settings\Owner\My

> Documents\java>javac HelloWorldApp.java

[b]

"after this command check,HelloWorldApp.class file is created or not..

If that calss file is not created then only this error occur"[/b]

> C:\Documents and Settings\Owner\My

> Documents\java>java HelloWorldApp

> Exception in thread "main"

> java.lang.NoClassDefFoundError: HelloWorldApp

>

>

> That's what happened.

Message was edited by:

ramesh.shriram

ramesh.shrirama at 2007-7-9 5:02:12 > top of Java-index,Java Essentials,New To Java...
# 17

>same error when I try to run my first .class file

what happens when you try:

cd /d c:\

java -version

javac -version

echo %PATH%

... just post the output verbatim.

>can't even run applets on a webpage!

>deleted any previous Runtime Environment versions

that's in control panel ~ java

you removed the active JRE (aka JVM) for applets.

Message was edited by: corlettk - oops - didn't see page 2

corlettka at 2007-7-9 5:02:12 > top of Java-index,Java Essentials,New To Java...
# 18
> I tried the suggestion in a previous post:> java -classpath . HelloWorldAppDidn't I tell you to do that in one of your other posts? Try bookmarking some of your other posts and consulting those when you need help.
CaptainMorgan08a at 2007-7-9 5:02:12 > top of Java-index,Java Essentials,New To Java...