Error Package Javax.servlet.http Does Not Exist Import Javax.servlet.http
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Compile error: package javax.servlet does not exist up vote 36 down vote favorite 6 I have a package in which I import javax.servlet.* and javax.servlet.http.* When I try to compile it in command prompt I get the error package javax.servlet does not exist I use JDK 1.7.0 and Tomcat 6.0. java servlets compilation compiler-errors share|improve this question edited Feb 8 '12 at 12:27 BalusC 683k20824782695 asked Feb 8 '12 at 12:22 Karadous 55821436 add a comment| 8 Answers 8 active oldest votes up vote 46 down vote accepted You need to add the path to Tomcat 6's /lib/servlet-api.jar file to the compile time classpath. javac -cp .;/path/to/Tomcat/lib/servlet-api.jar com/example/MyServletClass.java The classpath is where Java needs to look for imported dependencies. It will otherwise default to the current folder which is included as . in the above example. The ; is the path separator for Windows; if you're using an Unix based OS, then you need to use : instead. share|improve this answer answered Feb 8 '12 at 12:26 BalusC 683k20824782695 1 true, but in the future consider using maven to solve this kind of problems for you –Kris Feb 8 '12 at 12:44 5 Or just an IDE like Eclipse. I'd however recommend continuing learning the hard way until you can almost dream it. Otherwise it will be hard to understand how IDEs work under the covers. –BalusC Feb 8 '12 at 12:46 thanks BalusC. it solved the problem. –Karadous Feb 8 '12 at 12:55 add a comment| up vote 5 down vote In a linux environment the soft link apparently does not work. you must use the physical path. for instance on my machine I have a softlink at /usr/share/tomacat7/lib/servlet-api.jar and using t
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up package javax.servlet.http does not exist up vote 10 down vote favorite 3 I have the jre7 and jdk1.7.0 installed along with the Tomcat 7.0 but http://stackoverflow.com/questions/9193228/compile-error-package-javax-servlet-does-not-exist it shows this error. servlet.http is not the only one that "does not exist", there are also other (servlet.) components. Can anybody help me with this? UPDATE: This error occurs when I try the follow command: javac -classpath servlet-api.jar WebTest.java java servlets share|improve this question asked Oct 5 '11 at 18:32 Andrew 2,320103870 1 Check your class path. How to check it depends on what IDE you are using. Probably the Tomcat libraries are not http://stackoverflow.com/questions/7665955/package-javax-servlet-http-does-not-exist included. –bdares Oct 5 '11 at 18:34 You don't say where or how the error occurs, so helping will be... tricky. –Dave Newton Oct 5 '11 at 18:34 Does not exist where? What IDE are you using? –Perception Oct 5 '11 at 18:36 I try to do it with Command Prompt –Andrew Oct 5 '11 at 18:37 then you are most likely missing the class path –ashutosh raina Oct 5 '11 at 18:39 | show 1 more comment 7 Answers 7 active oldest votes up vote 9 down vote accepted Your CLASSPATH variable does not point to the directory containing the javax classes. The CLASSPATH variable specifies where the java compiler should look for java class file resources. If it does not know to look in the javax directory, then it will never find the file(s) you are after. share|improve this answer answered Oct 5 '11 at 18:35 ashutosh raina 3,38462666 where is the javax directory? –Andrew Oct 5 '11 at 18:36 2 C:\Program Files\Tomcat-3.2.3\lib\servlet.jar –ashutosh raina Oct 5 '11 at 18:38 Assume that you have tomcat location like: c:\tomcat at the command promt type: set classpath=c:\tomcat\lib\servlet.jar –ashutosh raina Oct 5 '11 at 18:40 just extra advice any 3rd party library u might use will need to go into WEB-INF\lib
This Site Careers Other https://coderanch.com/t/412015/java/java/solve-package-javax-servlet-exist all forums Forum: Beginning Java package javax.servlet.http does not exist saravanan rajendran Ranch Hand Posts: 75 posted 8 years ago this is the error package code: import java.io.*; import javax.servlet.*; import javax.servlet.http.*; import javax.servlet.ServletException; import java.io.IOException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.asteriskjava.manager.AuthenticationFailedException; import org.asteriskjava.manager.ManagerConnection; import org.asteriskjava.manager.ManagerConnectionFactory; import org.asteriskjava.manager.TimeoutException; import org.asteriskjava.manager.action.OriginateAction; import org.asteriskjava.manager.response.ManagerResponse; import org.asteriskjava.manager.action.ManagerAction; public error package javax.servlet.http class Outbound extends HttpServlet { private ManagerConnection managerConnection; public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { PrintWriter out = response.getWriter(); //pasted from http://asterisk-java.org/development/tutorial.html :-) try { ManagerConnectionFactory factory = new ManagerConnectionFactory( "192.168.1.186", "admin", "1234"); // this.managerConnection = factory.createManagerConnection(); OriginateAction originateAction; ManagerResponse originateResponse; originateAction = new OriginateAction(); //originateAction.setChannel("SIP/YOUR_TRUNK_NAME/"+name); originateAction.setChannel("local"+'/'+"5101"); originateAction.setContext("default"); originateAction.setExten("284818"); originateAction.setPriority(new Integer(1)); originateAction.setTimeout(new Long(30000)); // connect to Asterisk and log in managerConnection.login(); // send the originate action and wait for a maximum of 30 seconds for Asterisk // to send a reply originateResponse = managerConnection.sendAction(origina
Site Careers Other all forums Forum: Beginning Java help me solve 'package javax.servlet does not exist' error srinivas pola Greenhorn Posts: 24 posted 8 years ago Hi, I am using tomcat6 and jdk1.5 I am not using any IDE and trying to compile the servlets through command prompt itself. The environment variables i have set are as follows: CLASS_PATH - C:\jdk1.5\lib;C:\tomcat6\lib\servlet-api.jar;C:\tomcat6\lib\jsp-api.jar;C:\tomcat6\webapps JAVA_HOME - C:\jdk1.5 Path - C:\jdk1.5\bin;C:\jdk1.5;C:\jdk1.5\jre\bin\server When i'm trying to compile the servlet i'm getting this error C:\tomcat6\webapps\HeadFirst\WEB-INF\classes\web>javac BeerSelectAction.java BeerSelectAction.java:3: package javax.servlet does not exist import javax.servlet.*; ^ BeerSelectAction.java:4: package javax.servlet.http does not exist import javax.servlet.http.*; ^ BeerSelectAction.java:7: cannot find symbol symbol: class HttpServlet public class BeerSelectAction extends HttpServlet { ^ BeerSelectAction.java:9: cannot find symbol symbol : class HttpServletRequest location: class com.example.web.BeerSelectAction public void doPost(HttpServletRequest request, ^ BeerSelectAction.java:10: cannot find symbol symbol : class HttpServletResponse Please help me solve this error. Thanks in advance. Jesper de Jong Java Cowboy Saloon Keeper Posts: 15543 43 I like... posted 8 years ago The error is here: CLASS_PATH - C:\jdk1.5\lib;C:\tomcat6\lib\servlet-api.jar;C:\tomcat6\lib\jsp-api.jar;C:\tomcat6\webapps The environment variable should be named CLASSPATH, not CLASS_PATH with an underscore in it. Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation srinivas pola Greenhorn Posts: 24 posted 8 years ago I could solve the problem Thanks Jesper srinivas pola Greenhorn Posts: 24 posted 8 years ago now i'm facing another problem... :roll: When i try to run the servlet i'm getting noclassdefinitionfound exception.. Here is my xml file: