| | |
NewBie to Java needs some Help PLEASE!!!
![]() |
•
•
Join Date: Aug 2005
Posts: 5
Reputation:
Solved Threads: 0
Hi All,
I've just started using java and created a "HelloDate" program which works 100%. After that I created a "HelloWorld" program which didn't work because I had made a mistake in the code. I then rectified the mistake, deleted the class and then recompiled the "HelloWorld" program and it created a new class BUT when I run it I get the same error that I got when I initially created the program. The error I'm getting is "Exception in thread "main" java.lang.NoClassDefFoundError: HelloWorld/java
Thanking you in advance
Randall
I've just started using java and created a "HelloDate" program which works 100%. After that I created a "HelloWorld" program which didn't work because I had made a mistake in the code. I then rectified the mistake, deleted the class and then recompiled the "HelloWorld" program and it created a new class BUT when I run it I get the same error that I got when I initially created the program. The error I'm getting is "Exception in thread "main" java.lang.NoClassDefFoundError: HelloWorld/java
Thanking you in advance
Randall
Are you by any means trying to run the java source file directly?
If you're commanding "java HelloWorld.java" you're actually trying to execute a class called 'java' in a package called 'HelloWorld'.
Compile the class using javac and then execute it using 'java HelloWorld' (while making sure your classpath is correctly set in either case).
If you're commanding "java HelloWorld.java" you're actually trying to execute a class called 'java' in a package called 'HelloWorld'.
Compile the class using javac and then execute it using 'java HelloWorld' (while making sure your classpath is correctly set in either case).
As people are clearly allowed to attack me but I'm not allowed to defend myself, I no longer post to this site.
•
•
Join Date: Aug 2005
Posts: 5
Reputation:
Solved Threads: 0
Hi there,
Sorry for only replying now....
I don't quite understand, are you meant to be compiling a class??. I thought once you compile your java file it automatically creates a class for you?. Anyhow, I have tried compiling it and got the following error : "java c: invalid flag: HelloWorld.class"
Any other ideas?, or am I being really stupid and getting what you're trying to say?
Regards
Randall
Sorry for only replying now....
I don't quite understand, are you meant to be compiling a class??. I thought once you compile your java file it automatically creates a class for you?. Anyhow, I have tried compiling it and got the following error : "java c: invalid flag: HelloWorld.class"
Any other ideas?, or am I being really stupid and getting what you're trying to say?
Regards
Randall
•
•
Join Date: Aug 2005
Posts: 80
Reputation:
Solved Threads: 2
It sounds like you already compiled the class. You should have the two files...
HelloWorld.java (this is where the Java code you wrote is)
HelloWorld.class (This should have been created when you ran 'javac HelloWorld.java')
To run HelloWorld you would just run the command 'java HelloWorld'.
Hope that helps...
-Fredric
HelloWorld.java (this is where the Java code you wrote is)
HelloWorld.class (This should have been created when you ran 'javac HelloWorld.java')
To run HelloWorld you would just run the command 'java HelloWorld'.
Hope that helps...
-Fredric
you're the one who's not paying attention. You might be a little less agressive when you're not getting an answer you understand, your behaviour is not making you any friends.
Your failure to get even the basic commandline syntax correct is your problem, not ours. People give you hints as to what to do, even spell it out for you, and still you don't get it.
Apparently you're not even trying, so why should we try to help you any further?
Your failure to get even the basic commandline syntax correct is your problem, not ours. People give you hints as to what to do, even spell it out for you, and still you don't get it.
Apparently you're not even trying, so why should we try to help you any further?
As people are clearly allowed to attack me but I'm not allowed to defend myself, I no longer post to this site.
•
•
Join Date: Aug 2005
Posts: 80
Reputation:
Solved Threads: 2
Java Syntax (Toggle Plain Text)
The error I'm getting is "Exception in thread "main" java.lang.NoClassDefFoundError: HelloWorld/java
This is a pretty generic error, and seems to be very common. It is telling you that whatever you typed after 'java' has no class definition (in this case it must have been 'HelloWorld.java' - going by the errror message you gave, which is wrong since the argument should only be 'HelloWorld'). This seems to be a problem with your understanding of how to properly compile/run a Java program, so please try what server_crash has already posted, and if you still have problems then post the error message that you are getting.
-Fredric
![]() |
Similar Threads
- A newbie needs help in Java ...... (Java)
- Help a newbie with some Java code please? (Java)
- newbie... Java load large picture :) Lit'l help plez (Java)
Other Threads in the Java Forum
- Previous Thread: cant construct rectangle
- Next Thread: Java Question
| Thread Tools | Search this Thread |
-xlint add android api applet application applications array arrays automation bank bi binary blackberry bluetooth chat class client code compile compiler component database development digit eclipse equation error event fractal freeze functiontesting game gameprogramming givemetehcodez graphics gui health html hyper ide idea image infinite input int integer j2me java javame javaprojects jetbrains jni jpanel jtable julia learningresources linux list login loop main map method methods mobile myregfun netbeans newbie nonstatic notdisplaying pearl problem program programming project qt recursion scanner screen scrollbar server set sms sort sorting spamblocker sql sqlserver string superclass swing system text-file thread threads tree variablebinding windows xor






