File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes IDEs, Version Control and other tools and the fly likes compile error from cmd prompt Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » IDEs, Version Control and other tools
Bookmark "compile error from cmd prompt" Watch "compile error from cmd prompt" New topic

compile error from cmd prompt

Ola Olusegun

Joined: Jun 13, 2013
Posts: 15
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.

Peter Johnson

Joined: May 14, 2008
Posts: 5852

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:


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.

JBoss In Action
I agree. Here's the link:
subject: compile error from cmd prompt
It's not a secret anymore!