File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem with setting classpath

 
Jayanth Mathavan
Greenhorn
Posts: 16
  • 0
  • 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.
D:\Workspace\FileHandling\com\aol\ch

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
4)
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?

Thanks,
Jayanth Mathavan
 
Raj Kumar Bindal
Ranch Hand
Posts: 418
  • 0
  • 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
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • 0
  • 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).
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic