0

I'm busy working with servlets now and when I try and compile them, I get erorrs stating that it can't find javax.servlet etc. Getting errors where I do the import statements to them.

So apparently I have to add that servlet.jar file to the CLASSPATH? And that file can be located (since I'm using Tomcat) under Tomcat\common\lib\servlet-api.jar.
So what I wana know is, what really is this "classpath" I've worked with it before a little, so I made stuff work without knowing what the classpath is in the first place..

Plus to add more things to the classpath, do you just use a " ; " in between the deff paths? as in Whatever\somefolder\thatfile.txt; Tomcat\common\lib\servlet-api.jar?

3
Contributors
5
Replies
6
Views
6 Years
Discussion Span
Last Post by peter_budo
1

It is the "path" on which "class"es will be searched for by the jvm/compiler.

Edit: And don't do this on the system environment CLASSPATH variable. I know I have told you this already, if running from a web container/app server place jars in the META-INF/lib directory (usually), if running/compiling from an IDE add the jars as references/libraries in the project properties/preferences for that project, if running from the command line using the -jar option then properly define the classpath attribute in the manifest file, if running/compiling from the command without the -jar option then use the -cp option.

Edited by masijade: n/a

0

Thank you! A short, plain English answer.. Other websites go completely over the top and leave me even more confuzed that before.
As for adding more classes to the ClassPath, do you just seperate them with a semicolon? ;

0

Thanks man! Really appreciate your help, you seem to have completely taken over the Java Forum here on DaniWeb. The only person that ever replies...

Click

0

Thanks man! Really appreciate your help, you seem to have completely taken over the Java Forum here on DaniWeb. The only person that ever replies...

Well you just offended another 8 people at least that are regulars here

Besides as masijade mentioned you shouldn't be messing with CLASSPATH or PATH variable, only in rarely cases, usually very old libraries requires you to add them there.
In day-to-day task you will add any necessary library through IDE or if more experienced you will use Maven to take of it for you

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.