• Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem with setting classpath  RSS feed

Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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,
package com.aol.ch;

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(ClassLoader.java:620)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:12
at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
at java.net.URLClassLoader.access$000(URLClassLoader.java:56)
at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)

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

Jayanth Mathavan
Ranch Hand
Posts: 418
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please set classpath by doing :

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

and run your file by doing :

java com.aol.ch.FilesEdit
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The reason is that after compiling with this package declaration, your class file's qualified name will be com.aol.ch.FilesEdit (not just "FilesEdit"), and this is found under the FileHandling directory (not the "ch" directory).
You have to be odd to be #1 - Seuss. An odd little ad:
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!