File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Problem with setting classpath Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Problem with setting classpath" Watch "Problem with setting classpath" New topic

Problem with setting classpath

Jayanth Mathavan

Joined: Nov 10, 2005
Posts: 16
Hi all,
I have a very basic doubt with regards to setting the class path for a java program.The Java program and class file is located in below mentioned directory.

The above java program has the package declaration,

From another directory(D:\test\) I set path as mentioned below,
>>set PATH=C:\Sun\SDK\jdk\bin;.;%PATH%
>>set CLASSPATH=%CLASSPATH%;D:\Workspace\FileHandling\com\aol\ch

and i run the java class file from the directory(D:\test\),I run using the below mentioned command.

>>java FilesEdit

and I get the below errors,

Exception in thread "main" java.lang.NoClassDefFoundError: FeedsEdit (wrong name
: com/aol/ch/FeedsEdit)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(
at Method)
at java.lang.ClassLoader.loadClass(
at sun.misc.Launcher$AppClassLoader.loadClass(
at java.lang.ClassLoader.loadClass(
at java.lang.ClassLoader.loadClassInternal(

I don't know what mistake am making but everything looks fine. Can someone please help me out?

Jayanth Mathavan
Raj Kumar Bindal
Ranch Hand

Joined: Apr 15, 2006
Posts: 418
Please set classpath by doing :

set CLASSPATH=D:\Workspace\FileHandling;%CLASSPATH%

and run your file by doing :

marc weber

Joined: Aug 31, 2004
Posts: 11343

The reason is that after compiling with this package declaration, your class file's qualified name will be (not just "FilesEdit"), and this is found under the FileHandling directory (not the "ch" directory).

"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
I agree. Here's the link:
subject: Problem with setting classpath
It's not a secret anymore!