Compiling and running a java program in command prompt

I have written a simple hello world program given below

package helloworld;

public class helloWorld 
    public static void main(String[] args)
        System.out.println("Hello, World!");

I'm using Windows 7 and have set my CLASSPATH and PATH variables in the environment variables window as

C:\Program Files\Java\jdk1.6.0_24\bin;

The program is located at


So, basically when i try to run it in my command prompt, the following happens


C:\Users\Admin\Documents\NetBeansProjects\javaAssignment\src\helloWorld>java helloWorld
Exception in thread "main" java.lang.NoClassDefFoundError: helloWorld (wrong name: helloworld/helloWorld)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(
at java.lang.ClassLoader.defineClass(
at Method)
at java.lang.ClassLoader.loadClass(
at sun.misc.Launcher$AppClassLoader.loadClass(
at java.lang.ClassLoader.loadClass(
Could not find the main class: helloWorld.  Program will exit.

The program seems to be compiling fine and does not throw any errors. But when i try to run it, it says than exceptions have occurred. I tried looking up on Google thinking that setting my PATH and CLASSPATH was wrong, but I don't seem to find any issues with that.


In case your file is in a package, you can run as follows :

java packageName.helloWorld

Run the code from outside the helloworld package directory i.e from src directory (C:\Users\Admin\Documents\NetBeansProjects\javaAssignment\src)

Also check if the name of your java file is the same as your class name (

Also it seems that the name of your package is helloworld (all in small letters) however the folder name is helloWorld (note that W is capital) both the names need to match.

Need Your Help

Problem with Symfony form validation

forms symfony1 validation symfony-1.4

I'm unable to see what I may be doing wrong with the following Symfony 1.4 form validation. Basically, all I just want is for all four conditions to be taken correctly into account (required, min-l...

commandLink/commandButton/ajax backing bean action/listener method not invoked

jsf jsf-2 action commandbutton commandlink

I found a problem when using the <h:commandLink> or <h:commandButton> in an include page: the action and actionListener associated with the UICommand component are simply not being invo...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.