• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to include jars in command line classpath?

 
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
when i am compiling a servlet in a command line,as
C:\doct\document\filter\WEB-INF\classes>javac filter.java
its says HTTP request and response is not recognized.

previously there was a method which i have done to fix this problem,but i forget that procedure,somthing i remember,i us to copy some file from apache tomcat to some other location.
i have tomcat6,its working,all enviornment varible has been set.

thank you.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You should not have to copy any files. SImply add the jar files, where they sit, to the command line classpath.
 
abhishek rathur
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yaa i think it was jar files.
where i would get it from.From apache tomcat folder??
please specify the path where those jar files are found in apache tomcat folder.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's called servlet-api.jar, if memory serves. A quick file search will find it for you.
 
abhishek rathur
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i need the exact location of those jar files.
i have done it before,but i forget it now.
its in the apache tomcat folder,somwhere i don't know where.
 
abhishek rathur
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
the errors which i am getting.


D:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\abhishek\WEB-INF\
classes>javac demo.java
demo.java:1: package javax.servlet does not exist
import javax.servlet.*;
^
demo.java:2: package javax.servlet.http does not exist
import javax.servlet.http.*;
^
demo.java:4: cannot find symbol
symbol: class HttpServlet
public class demo extends HttpServlet
^
demo.java:8: cannot find symbol
symbol : class ServletConfig
location: class demo
public void init(ServletConfig s)
^
demo.java:13: cannot find symbol
symbol : class HttpServletRequest
location: class demo
public void service(HttpServletRequest req,HttpServletResponse res)
^
demo.java:13: cannot find symbol
symbol : class HttpServletResponse
location: class demo
public void service(HttpServletRequest req,HttpServletResponse res)
^
6 errors

D:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\abhishek\WEB-INF\
classes>
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, that means you need to include the servlet jar file. Show some initiative and look in your Tomcat folder structure to find it.
 
abhishek rathur
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ok i found servlet jar files,where i need to place it.
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nowhere. Just include the jar file in your command line.

If you don't know how to do that, just say so and I'll move this to the Beginning Java forum.
 
abhishek rathur
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
no i dont know...
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK, I'll move this to the appropriate forum with a change of subject.
 
Ranch Hand
Posts: 69
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Abhishek,

Compile --> "javac -cp <jar_ file_name> <java_file_name>"
Run ---> "javac -cp <jar_ file_name>;.; <java class>"

Regards,
Anila.
 
abhishek rathur
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thank you anila for your reply.
but i fixed the problem in some other way,i copied all the jar file from the tomcat home to the jave lid/ext folder as the result the above problem is solved,no need to set the class path.
really coool.
thanks again to all Bear Bibeault too.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic