• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to include jars in command line classpath?

 
abhishek rathur
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • 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.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64959
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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
  • 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.
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
Author and ninkuma
Marshal
Pie
Posts: 64959
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
ok i found servlet jar files,where i need to place it.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64959
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
no i dont know...
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64959
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, I'll move this to the appropriate forum with a change of subject.
 
Anila Mathew
Ranch Hand
Posts: 69
Java
  • Mark post as helpful
  • send pies
  • 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
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic