Jakarta

So I have openJDK 11 and 20. I have eclipse 2023-03 4.27. I am running Tomcat 10. But when I paste in the HelloWorld code it shows problems because it doesnt seem to see any Jakarta libraries. I have looked through you tutorial and even searched for answers and I am not seeing any. Please help?

Have you added Jakarta to your classpath?

I am also having issues with Jakarta in tomcat 10 (version 10.1.x for me, not sure if that’s the same as OP)

Here is the description of the problem and my attempts at solving it (including trying to add jakarta to the classpath)

I started going through your Java Server Tutorials a few years ago, and took a break. I am now returning. The version of tomcat I am using is 10.1.10. The version displayed in your tutorial (at least at the very beginning of the server tutorial) is 10.0.7.

In your example of introductions to Servlets, you have these import statements:

import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

When I go to compile this file to generate the class file, I encounter the following errors that suggest there is something that isn’t quite right with the jakarta files for tomcat 10.1.10

C:\Users\User\Desktop\Computer Science\apache-tomcat-10.1.10-windows-x64\apache-tomcat-10.1.10\webapps\HelloWorld\WEB-INF\HelloWorldClass\HelloWorldServlet.java:6: error: package jakarta.servlet.annotation does not exist
import jakarta.servlet.annotation.WebServlet;
^
C:\Users\User\Desktop\Computer Science\apache-tomcat-10.1.10-windows-x64\apache-tomcat-10.1.10\webapps\HelloWorld\WEB-INF\HelloWorldClass\HelloWorldServlet.java:7: error: package jakarta.servlet.http does not exist
import jakarta.servlet.http.HttpServlet;
^
C:\Users\User\Desktop\Computer Science\apache-tomcat-10.1.10-windows-x64\apache-tomcat-10.1.10\webapps\HelloWorld\WEB-INF\HelloWorldClass\HelloWorldServlet.java:8: error: package jakarta.servlet.http does not exist
import jakarta.servlet.http.HttpServletRequest;
^
C:\Users\User\Desktop\Computer Science\apache-tomcat-10.1.10-windows-x64\apache-tomcat-10.1.10\webapps\HelloWorld\WEB-INF\HelloWorldClass\HelloWorldServlet.java:9: error: package jakarta.servlet.http does not exist
import jakarta.servlet.http.HttpServletResponse;

I have tried adding jakarta to the classpath for the HelloWorld example file with the following command (and I end up encountering the same above errors when doing so)

javac -classpath “c:\users\user\desktop\computer science\apache-tomcat-10.1.10-windows-x64\lib\servlet-api.jar” “C:\Users\User\Desktop\Computer Science\apache-tomcat-10.1.10-windows-x64\apache-tomcat-10.1.10\webapps\HelloWorld\WEB-INF\HelloWorldClass\HelloWorldServlet.java”

I am wondering if you can help me identify what the issue is. I’ve gone into the tomcat lib directory, and I don’t see a jar file in there labeled “jakarta”. The only jar file I see with “jakarta” in the name is “jakartaee-migration-1.0.7-shaded”

I’ve tried googling this, but almost all results reference “javax” rather than jakarta. I don’t even seem to be obtaining any results from the apache tomcat project itself.

Any help is greatly appreciated. Thanks!