• Post Reply Bookmark Topic Watch Topic
  • New Topic

Compile error in Eclipse: package javax.servlet does not exist  RSS feed

 
A Kao
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I downloaded the source codes of the book "Java Web Services - Up and Running".
I modified the build.xml file of the first chapter in order to make it to run with Wildfly-10.1.0.Final.



I run the build.xml file as Ant build in Eclipse and get the following output:
compile:
    [javac] /home/akao/workspace/Java Web Services - Up and Running/ch1/jspService/build.xml:164: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds
    [javac] Compiling 2 source files to /home/akao/workspace/Java Web Services - Up and Running/ch1/jspService/build/WEB-INF/classes
    [javac] /home/akao/workspace/Java Web Services - Up and Running/ch1/jspService/src/predictions/Predictions.java:9: error: package javax.servlet does not exist
    [javac] import javax.servlet.ServletContext;



Eclipse version is Java EE IDE for Web Developers.
Version: Neon.1a Release (4.6.1)
Build id: 20161007-1200

$ java -version
java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) Server VM (build 25.121-b13, mixed mode)

$ ant -version
Apache Ant(TM) version 1.10.1 compiled on February 2 2017
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 36660
475
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to download a java ee or servlet jar and reference it in the classpath properties in your build.xml. I don't see that on the screen. Can you post the full build.xml if you can't find it?
 
Rob Spoor
Sheriff
Posts: 20946
81
Chrome Eclipse IDE Java Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You don't need to download it, WildFly comes with a copy. All of its libraries are located in <WildFly home>/modules/system/layers/base. From there, locate the matching folder. For the Servlet API that's javax/servlet/api/main/jboss-servlet-api_3.1_spec-1.0.0.Final.jar or something similar, but you can also find JSP, JSTL, JPA, etc.
 
A Kao
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob Spoor wrote:You don't need to download it, WildFly comes with a copy. All of its libraries are located in <WildFly home>/modules/system/layers/base. From there, locate the matching folder. For the Servlet API that's javax/servlet/api/main/jboss-servlet-api_3.1_spec-1.0.0.Final.jar or something similar, but you can also find JSP, JSTL, JPA, etc.


Thank you for your advice!
Problem is solved!
build.xml is modified to:
 
Rob Spoor
Sheriff
Posts: 20946
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!