-
error with my first program
i downloaded the j2sdk-1_4_2_11-nb-5_0-win set it up on my pc am runnin winXP am learnin from how java how to program 5th edition but i keep gettin this error when i try to run the simple welcome prog.
"Exception in thread "main" java.lang.NoClassDefFoundError: welcome/java"
if any one can help plz do it
-
The interpreter is looking for a class called "welcome/java" which is supported in the "main" method of your class and cannot find it. Sounds as if there is a typo in your class file.
-
wut class
the book didnt tell me to make any classes here is the code am tryin to run
public class welcome1
{
public static void main( String args [])
{
System.out.println("welcome to java programming");
}
}
-
How are you executing your program? (in NetBeans or at the command prompt?)
-
-
javac
i used the javac command after settin the path and classpath and i get that error
welcome.java:1: class welcome1 is public, should be declared in a file named wel
come1.java
public class welcome1
^
1 error
am i missin somethin?
-
No, that is absolutely correct. The name of the java file should be the name of the class.
-
then wuts wrong lizard0o_1@hotmail.com add me plz we can talk there so i can get wut am missin
-
is your java code file named welcome1.java? The compiler doesn't think so.
-
no my file named welcome.java not welcome1 and the command i use in cmd is java welcome.java or javac welcome.java
-
Then either change the name of the file to welcome1.java, or change the line in your code
public class welcome1
to
public class welcome
-
thanx alot for ur help but still havin a prob i changed the file name to welcome1 when i call command javac welcome1.java it created a welcome1.class file but no out put on the screen and when i call the java welcome1.java i get the first error
F:\sana 4\start my java\welcome>javac welcome1.java
F:\sana 4\start my java\welcome>java welcome1.java
Exception in thread "main" java.lang.NoClassDefFoundError: welcome1/java
wut do u think it is this time
-
When you invoke the java interpreter (java ... ) the command is "java welcome1" - you are "executing" the welcome1.class file produced by the compiler.
The compiler, if there are no error messages or warnings, just returns the command prompt. So what you are seeing is the expected outcome of the compilation of a properly formed program.
So, now try to run the compiled code by typing
java welcome1
at the command prompt.
Last edited by nspils; 10-28-2006 at 12:07 PM.
-
it worked at last my first code in java run with no errors lol thanx alot
-
And, I trust, far from the last code you will run in java with no errors. Good luck in your exploration of the language!
Similar Threads
-
By divagoddess in forum C++
Replies: 5
Last Post: 08-14-2009, 03:12 PM
-
By stormswimmer in forum Java
Replies: 2
Last Post: 01-02-2006, 03:17 PM
-
By Gordon Reichhardt in forum VB Classic
Replies: 2
Last Post: 01-08-2002, 10:06 AM
-
By W.Pierce in forum VB Classic
Replies: 1
Last Post: 12-11-2001, 08:28 AM
-
Replies: 0
Last Post: 12-15-2000, 10:07 PM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks