Java Servlet Package Does Not Exist Error
Contents |
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 java: package javax.servlet does not exist about Stack Overflow the company Business Learn more about hiring developers or posting package javax.servlet does not exist maven ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack
Package Javax.servlet Does Not Exist Netbeans
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
Package Javax.servlet.http Does Not Exist Ant Build
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 684k20924822698 asked Feb 8 '12 at 12:22 Karadous 55821436 add a comment| 8 Answers 8 active package javax.servlet does not exist eclipse 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 684k20924822698 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
here for a quick overview of the site Help Center Detailed answers to any questions
Package Javax.servlet.jsp Does Not Exist
you might have Meta Discuss the workings and policies of package javax.servlet does not exist in ubuntu this site About Us Learn more about Stack Overflow the company Business Learn more about hiring package javax.servlet.jsp does not exist maven 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 http://stackoverflow.com/questions/9193228/compile-error-package-javax-servlet-does-not-exist a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Compiling servlet: package javax.servlet does not exist up vote 0 down vote favorite I have a problem with this servlet program while compiling it on cmd,I have set class path of weblogic.jar http://stackoverflow.com/questions/28753336/compiling-servlet-package-javax-servlet-does-not-exist file by using this on cmd - set classpath=C:\Oracle\Middleware\wlserver_12.1\server\lib\weblogic.jar; My code is- import javax.servlet.http.*; import javax.servlet.*; import java.io.*; public class DemoServlet1 implements Servlet { public void init(ServletConfig con) {} public void service(ServletRequest req,ServletResponse res)throws ServletException,IOException { res.setContentType("text/html"); PrintWriter out=res.getWriter(); out.println("
"); out.println("hello servlet !!!!"); out.println(""); } public void destroy() {} public ServletConfig getServletConfig() { return null; } public String getServletInfo() { return null; } } Error message- C:\javaharsh\Demo>set class path=C:\Oracle\Middleware\wlserver_12.1\server\lib\w eblogic.jar; C:\javaharsh\Demo>javac DemoServlet1.java DemoServlet1.java:1: error: package javax.servlet.http does not exist import javax.servlet.http.*; ^ DemoServlet1.java:2: error: package javax.servlet does not exist import javax.servlet.*; ^ DemoServlet1.java:4: error: cannot find symbol public class DemoServlet1 implements Servlet ^ symbol: class Servlet DemoServlet1.java:6: error: cannot find symbol public void init(ServletConfig con) ^ symbol: class ServletConfig location: class DemoServlet1 DemoServlet1.java:8: error: cannot find symbol public void service(ServletRequest req,ServletResponse res)throws Servle tException,IOException ^ symbol: class ServletRequest location: class DemoServlet1 DemoServlet1.java:8: error: cannot find symbol public void service(ServletRequest req,ServletResponse res)throws Servle tException,IOException ^ symbol: class ServletRCertification Databases Caching https://coderanch.com/t/624141/java/package-javax-servlet-exist-error Books Engineering Languages Frameworks Products This Site Careers http://www.jguru.com/faq/view.jsp?EID=413601 Other all forums Forum: Beginning Java 'package javax.servlet does not exist' error is coming Megha Singhal Ranch Hand Posts: 225 I like... posted 2 years ago i am using Tomcat does not 7.0 and java jdk1.7.0 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: C:\Program Files\Java\jdk1.7.0\lib; CLASSPATH: C:\Program Files\Apache Software Foundation\Tomcat 7.0\common\lib\servlet-api.jar;C:\Program Files\Apache does not exist Software Foundation\Tomcat 7.0\lib\commons-fileupload-1.2.1.jar;C:\Program Files\Apache Software Foundation\Tomcat 7.0\lib\commons-io-1.3.2.jar;C:\Program Files\Java\jdk1.7.0\bin;C:\Program Files\Java\jre7\bin; JAVA_HOME: C:\Program Files\Java\jdk1.7.0; Path: C:\Program Files\Java\jdk1.7.0\bin; when i am trying to compile servlet program following error is coming C:\>cd C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\userregist er\WEB-INF\classes C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\userregister\WEB- INF\classes>javac NewServlet.java NewServlet.java:1: error: cannot find symbol import java.io; ^ symbol: class io location: package java NewServlet.java:2: error: package javax.servlet does not exist import javax.servlet.*; ^ NewServlet.java:3: error: package javax.servlet.http does not exist import javax.servlet.http.*; ^ NewServlet.java:4: error: cannot find symbol public class NewServlet extends HttpServlet { ^ symbol: class HttpServlet NewServlet.java:5: error: cannot find symbol protected void processRequest(HttpServletRequest request, HttpServletResponse response) ^ symbol: class HttpServletRequest location: class NewServlet NewServlet.java:5: error: cannot find symbol protected
Mobile Media API Other Certification Server-Side Java Web Services & Cloud Downloads Learn Forums Newsletter Close Home / FAQ / Java Tools / Tomcat Why do I get the compiler error "package javax.servlet does not exist" or "package javax.servlet not found in import"? Created May 4, 2012 Tweet Kursat Demirezen Try this: Assume that you have tomcat location like: c: omcat at the command promt type: set classpath=c: omcatlibservlet.jar Post a comment Email Article Print Article Share Articles Digg del.icio.us Newsvine Facebook Google LinkedIn MySpace Reddit Slashdot StumbleUpon Technorati Twitter Windows Live YahooBuzz FriendFeed Please enable Javascript in your browser, before you post the comment! Now Javascript is disabled. 0 Comments (click to add your comment) Comment and Contribute Your name/nickname Your email WebSite Subject (Maximum characters: 1200). You have 1200 characters left. Most Popular jGuru Stories Editor's Picks Most Popular The Java Game Development Tutorial Files and Directories in Java Load Testing your Applications with Apache JMeter Unit Testing Java Programs Using SOAP with Java Repeating Annotations in Java 8 About | Sitemap | Contact