• Post Reply Bookmark Topic Watch Topic
  • New Topic

real newbye and his first code error  RSS feed

 
Pier Maccà
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everybody I just started a class about Java with the support of an old book (Java 5) and the result of my first exercise is this:



and the error that follows is this

java.lang.NoClassDefFoundError: NumeroIntero
Exception in thread "main"
Process Terminated... there were problems.

what am I doing wrong?
 
Campbell Ritchie
Marshal
Posts: 56546
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

Try the following instructions at the command lije:
javac NumeroIntero.java
javac ClasseRichiesta.java
java ClasseRichiesta


Then tell us what happens.
 
Pier Maccà
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Happens that it works! Why wasn't it before?
 
Campbell Ritchie
Marshal
Posts: 56546
172
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well done

Obviously you had previously not compiled every class and the Numero .class file was missing.
 
Campbell Ritchie
Marshal
Posts: 56546
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you give the classes package names? If you have a package name you may find that
javac ClasseRichiesta.java
does not compile the Numero Intero file.
 
Pier Maccà
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I didn't even know about packages before you talked about them actually, so no, by the way I compiled the classes one by one, is the way to compiling classes with package names different?
 
Campbell Ritchie
Marshal
Posts: 56546
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, it is, but at your stage it is probably best not to know about packages. When you are a bit more experienced and are writing applications with 20 classes, then look in the Java® Tutorials.
 
Pier Maccà
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok I will go on step by step. Thank you very much for your answers and your kindness : )
 
Knute Snortum
Sheriff
Posts: 4279
127
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pier, I formatted your code in your original post by using code tags and indenting. It's considered good form to UseCodeTags (← click) when you post.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!