File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes How to set class path during compilation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "How to set class path during compilation" Watch "How to set class path during compilation" New topic

How to set class path during compilation

Jithesh Kozhipurath
Ranch Hand

Joined: Aug 27, 2003
Posts: 76
Hai friends ,
I have a program in servelet it displays an error during compilation,the error is,
cz\samba\projects\arc\analyse\ cannot access
bad class file: .\cz\samba\projects\arc\analyse\sk\skultety\websitexml\WebPageCo
class file contains wrong class: sk.skultety.websitexml.WebPageConfig
Please remove or make sure it appears in the correct subdirectory of the classpa
private WebPageConfig webPageConfig;
1 error
But the class is there in the correct path. Please help me its so urgent

Jithesh K
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8927

use SET CLASSPATH =classedirectory

Tom Blough
Ranch Hand

Joined: Jul 31, 2003
Posts: 263
javac -classpath ./sk/skultety/websitexml/ <source>

Tom Blough<br /> <blockquote><font size="1" face="Verdana, Arial">quote:</font><hr>Cum catapultae proscriptae erunt tum soli proscripti catapultas habebunt.<hr></blockquote>
David O'Meara

Joined: Mar 06, 2001
Posts: 13459

I think the problem is a little bit more than that.
You have the class sk.skultety.websitexml.WebPageConfig
It appears to exist in the directory '.\cz\samba\projects\arc\analyse\' ie a directory relative to somewhere.
The directory '.' is included on your classpath.
When you import it, you are trying to import the class as This is not the fuly qualified class name. (see above)
Firstly you need to make sure the directory '.\cz\samba\projects\arc\analyse\' is on your classpath, then refer to class by its correct name.
I think. It's all very confusing.
Another point that needs to be made is that the two examples given above are not the correct way to add classes to the classpath for web applications. You may be better off putting the source in the web-inf\classes directory of the web server.
ramdas pradeep kumar
Ranch Hand

Joined: Aug 27, 2003
Posts: 36
i think u are trying to compile it from outside the file dir
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 13036
Just take some time out and learn how to use ANT to build servlet projects. You will be glad you did. You can completely avoid setting environment variables for specific projects.
Moose bites can be very painful!
I agree. Here's the link:
subject: How to set class path during compilation
It's not a secret anymore!