Mar 14, 2008

javax.servlet cannot be resolved when using Java 6

Error Message

The import javax.servlet cannot be resolved when using Java 6

Description

Java 5 uses the j2ee.jar library for javax.servelet where Java 6 uses the javaee.jar library

Solution

Add javaee.jar to the project class path. Note: Use the jdk or skd and not the jre.
In Eclipse > Project Properties > Java Build Path > Add External JARs > javaee.jar which can be found in the %JAVA_HOME%\sdk\lib

1 comment:

lontu l├Ávikutsu said...

This can be also obtained from servlet-api-2.4.jar or servlet-api-2.5.jar. I have no javaee.jar or any other java ee thing on my installation of Ubuntu even if I have installed sun-java6-jdk.