0

I have been using java for last few days,I am getting an issue form last few days. When i am trying to create a class in servlet the package section is showing the following error "**

  • The type java.io.ObjectInputStream cannot be resolved. It is indirectly referenced from required .class files

    while i try to comment out the

  • import javax.servlet.http.HttpServlet;

**" section the error is going, but for that i cant extend the httpservlet class. please help me out for this issue.

This image shows the error:

This image shows the error

Mohammad Sadiqur Rahman
  • 5,379
  • 7
  • 31
  • 45
Sunny Dey
  • 1
  • 1

1 Answers1

1

Include servlet-api-3.1.jar in your dependencies.

Maven

<dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>javax.servlet-api</artifactId>
    <version>3.1.0</version>
    <scope>provided</scope>
</dependency>

Gradle

configurations {
    provided
}
sourceSets {
    main { compileClasspath += configurations.provided }
}
dependencies {
    provided 'javax.servlet:javax.servlet-api:3.1.0'
}
Daniccan
  • 2,755
  • 1
  • 18
  • 27
  • The following links may be useful, https://stackoverflow.com/questions/18075343/java-project-in-eclipse-the-type-java-lang-object-cannot-be-resolved-it-is-ind https://stackoverflow.com/questions/36963248/the-type-java-io-objectinputstream-cannot-be-resolved-it-is-indirectly-referenc – Daniccan Jun 29 '17 at 11:00