Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

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

 
Greenhorn
Posts: 19
  • 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
 
author & internet detective
Posts: 40035
809
Eclipse IDE VI Editor Java
  • 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?
 
Sheriff
Posts: 21971
106
Eclipse IDE Spring VI Editor Chrome Java Ubuntu 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: 19
  • 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: 21971
106
Eclipse IDE Spring VI Editor Chrome Java Ubuntu Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome.
 
Something about .... going for a swim. With this tiny ad ...
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic