File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes How to include jars in command line classpath? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "How to include jars in command line classpath?" Watch "How to include jars in command line classpath?" New topic
Author

How to include jars in command line classpath?

abhishek rathur
Ranch Hand

Joined: Jan 14, 2010
Posts: 66
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

Joined: Jan 10, 2002
Posts: 61202
    
  66

You should not have to copy any files. SImply add the jar files, where they sit, to the command line classpath.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
abhishek rathur
Ranch Hand

Joined: Jan 14, 2010
Posts: 66
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
Marshal

Joined: Mar 22, 2005
Posts: 41833
    
  63
It's called servlet-api.jar, if memory serves. A quick file search will find it for you.


Ping & DNS - my free Android networking tools app
abhishek rathur
Ranch Hand

Joined: Jan 14, 2010
Posts: 66
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

Joined: Jan 14, 2010
Posts: 66
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

Joined: Jan 10, 2002
Posts: 61202
    
  66

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

Joined: Jan 14, 2010
Posts: 66
ok i found servlet jar files,where i need to place it.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61202
    
  66

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

Joined: Jan 14, 2010
Posts: 66
no i dont know...
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61202
    
  66

OK, I'll move this to the appropriate forum with a change of subject.
Anila Mathew
Ranch Hand

Joined: Jun 16, 2004
Posts: 69

Abhishek,

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

Regards,
Anila.
abhishek rathur
Ranch Hand

Joined: Jan 14, 2010
Posts: 66
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to include jars in command line classpath?