Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Adding CLASSPATH

 
Sumukh Deshpande
Ranch Hand
Posts: 87
Firefox Browser IntelliJ IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When do we typically need to add the path of the directory of .class files into CLASSPATH variable.
Is that useful for compiling the servlets files? I am not getting the exact use of it.
I read about this in a book named Core Servlets Volume-I 2nd Edition. Page 57 , Second chapter, Topic - Updating your CLASSPATH.
I am using Tomcat 5.5.28.

Thanks in advance.

 
Vijitha Kumara
Bartender
Posts: 3913
9
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are working with servlets then you have to add servlet-api.jar (found in the tomcat's lib directory) to the CLASSPATH in order to compile your servlets. CLASSPATH is for pointing the compiler which places to look for classes/jar files etc.. which are not part of the core Java library but from the third parties. And you need that same additional classes/jar files when you run the program in order to let the JVM use them too.
 
Sumukh Deshpande
Ranch Hand
Posts: 87
Firefox Browser IntelliJ IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Vijitha Kumara. That answers my question.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13064
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
However - it is important to remember that Tomcat does NOT use the CLASSPATH environment variable to run servlets. Tomcat has its own - rather complicated - rules which control where it looks for classes and library jar files. Your Tomcat installation should have a "class-loader-howto.html" file which explains this.

Bill
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic