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 cannot find symbol Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "cannot find symbol" Watch "cannot find symbol" New topic
Author

cannot find symbol

preethi Ayyappan
Ranch Hand

Joined: Oct 04, 2007
Posts: 518
Hi,

I am getting the following error when running my servlet program in my linux machine.

The error is:

Outbound.java:3: package javax.servlet does not exist
import javax.servlet.*;
^
Outbound.java:4: package javax.servlet.http does not exist
import javax.servlet.http.*;
^
Outbound.java:16: cannot find symbol
symbol: class HttpServlet
public class Outbound extends HttpServlet {
^
Outbound.java:18: cannot find symbol
symbol : class HttpServletRequest
location: class Outbound
public void doGet(HttpServletRequest request,
^
Outbound.java:19: cannot find symbol
symbol : class HttpServletResponse
location: class Outbound
HttpServletResponse response)
^
Outbound.java:20: cannot find symbol
symbol : class ServletException
location: class Outbound
throws ServletException, IOException {
^
Note: Outbound.java uses or overrides a deprecated API.
Note: Recompile with -Xlint eprecation for details.
6 errors



I have created a project folder named "webproject"inside /usr/local/apache-tomcat/webapps and created a folder named WEB-INF and web.xml file.Inside the WEB-INF i have created a folder classes.i have put my servlet code in side classes and tried to compile.but i am getting the error.please help me to solve this error.

Thanks
gopi sri
Greenhorn

Joined: Nov 11, 2008
Posts: 6
hai preethi

you not set the classpath for your web server... which web server you using to support your servlet files ?.

set the classpath for your webserver, your errors will be rectified.

Tell to Difficulties iam very difficult..gud luck preethi

regards
gopi
gopinath65@gmail.com
arulk pillai
Author
Ranch Hand

Joined: May 31, 2007
Posts: 3250
Looks like you are missing the servlet-api.jar. Possibly other jars as well.


500+ Java Interview Questions and Answers | Java job hunting know how & Java resumes
preethi Ayyappan
Ranch Hand

Joined: Oct 04, 2007
Posts: 518
Thanks gopi sri .I am using tomcat webserver.It is in the path /usr/local.How should i set the path for this and where i have to set the path?

arulk,
I am having the servlet-api,servlet jar files in /usr/local/apache-tomcat/common/lib and also in /usr/java/jdk/bin and also in /usr/java/jdk/jre/bin. what else i have to add in which path?

[ November 12, 2008: Message edited by: preethi Ayyappan ]
[ November 12, 2008: Message edited by: preethi Ayyappan ]
Dilip Mallik
Ranch Hand

Joined: Sep 19, 2008
Posts: 40
Preethi If you want to compile your servlet
then set classpath to the servlet-api.jar
and then compile , Your compilation problem will be solved
Bye
gopi sri
Greenhorn

Joined: Nov 11, 2008
Posts: 6
hello preethi....
oh great you are using good web server..you set the classpath for your web server using servlet-api.jar file.

goto->mycomputer->rightclick->properties->press Advance tab-> click EnvironmentVariables-> window open

you should enter following
variable name : classpath
variable value: D:\apache-tomcat-6.0.14\lib\servlet-api.jar;
OR
/usr/local/apache-tomcat/common/lib\servlet-api.jar;

i given D:\apache .. since i have apache tomacat in D: drive !! you enter the path where you apached is located..

tak care,
gopi
gopinath65@gmail.com
Amit Ghorpade
Bartender

Joined: Jun 06, 2007
Posts: 2716
    
    6

If it is present at multiple places then anyone can do, but make sure you dont run into version problems.I'll say add /usr/local/apache-tomcat/common/lib to your classpath.
More on compiling servlets here .
BTW gopi sri, preethi is using Linux and not Windows
[ November 12, 2008: Message edited by: Amit Ghorpade ]

SCJP, SCWCD.
|Asking Good Questions|
preethi Ayyappan
Ranch Hand

Joined: Oct 04, 2007
Posts: 518
Thanks.I have set classpath like export CLASSPATH=/usr/local/apache-tomcat/common/lib in /etc/profile.But till the error occurs.I gave the above in the console like export CLASSPATH=/usr/local/apache-tomcat/common/lib:$CLASSPATH also and tried to compile.But i am getting the same error.I am having servlet and servlet-api.jar files in the path /usr/local/apache-tomcat/common/lib
[ November 12, 2008: Message edited by: preethi Ayyappan ]
Bennet Xavier
Ranch Hand

Joined: Jun 19, 2008
Posts: 162
Hi preethi Ayyappan,

set classpath for each jar files separatly.

the Tomcat or java compiler wont take if you specify the path till lib.

classpath in environment varable: "C:\Tomcat 6.0\lib\servlet-api.jar"

Thanks & Regards,

Bennet Xavier.X


Thanks And Regards

Bennet Xavier. X
preethi Ayyappan
Ranch Hand

Joined: Oct 04, 2007
Posts: 518
I am having problem even in accessing the servler-examples project which is given in default.When i tried to access the tomcat page i can able to view that page.But when i tried to access http://192.168.1.147:8080/servlets-examples,i am getting the following error:

HTTP Status 404 - /servlets-examples

type Status report

message /servlets-examples

description The requested resource (/servlets-examples) is not available.
Apache Tomcat/5.5.26


why it happens.It is also due to any class path problem or tomcat is not installed properly?
Vijay Jeyam
Greenhorn

Joined: Nov 12, 2008
Posts: 15
Make sure that your TOMCAT,Catalina and Java home are set correctly.

If possible use ANT/maven scripts to compile and deply your application


Never Never Never Give Up...!!!
preethi Ayyappan
Ranch Hand

Joined: Oct 04, 2007
Posts: 518
Thank you all.I have solved the problem by compiling it like
javac -cp servlet-api.jar:servlet.jar:mysql-connector-java-3.0.17-ga-bin.jar:.:asterisk-java-0.3.1.jar Outbound.java.

Now it compiles well. but tomcat projects are not opened and displaying error
rakesh sugirtharaj
Ranch Hand

Joined: Dec 16, 2007
Posts: 151
but tomcat projects are not opened and displaying error

Kindly explain more the issue you are facing. This is too fuzzy! :roll:


Cheers!
RSR
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: cannot find symbol