• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

compile error from cmd prompt

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,
When i used notepad++ to write the code below, I compiled it in command prompt and got the following error message.I wonder why it is running in Net beans . The error message. Exception in thread "main" java.lang.NoClassDefFoundError ifThenElse <wrong name: ifThenElse/ifThenElse> .It had some package extensions below.

 
author
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think what you are missing is the correspondence between directories and package names. The package name in your class is ifThenElse, and the class name is ifThenElse. Therefore, you need to have this relative file path: ./ifThenElse/ifThenElse.class.

Let's assume you are on Windows and the source file is located here:

c:\mySimpleApp\ifThenElse\ifThenElse.java

You need to have a command prompt open at c:\mySimpleApp. In that command prompt you can enter:

javac ifTheElse\*.java

to compile the code and then enter:

java -cp . ifThenElse.ifThenElse

to run the app.

When using an IDE like Netbeans or Eclipse, it usually handles all of this package/folder correspondence for you. But knowing how to do this using a simple editor such as Notepad++ and doing everything from the command line is a good way to learn subtle points like this about Java.

Finally, by convention, class names usually start with initial caps.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic