• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Sheriff
Posts: 22781
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 22781
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You're welcome.
reply
    Bookmark Topic Watch Topic
  • New Topic