Link to home
Start Free TrialLog in
Avatar of cofactor
cofactor

asked on

java code not compiling

Java code not compiling.

Error


javac -cp C:\apache-tomcat-8.5.83\lib\servlet-api.jar Search.java
Search.java:3: error: cannot find symbol
import javax.servlet.ServietException;
                    ^
  symbol:   class ServietException
  location: package javax.servlet
Search.java:7: error: cannot find symbol
throws ServletException, IOException {
       ^
  symbol:   class ServletException
  location: class Search
2 errors

Open in new window


I opened the servlet-api.jar file. 

ServletException class is present there.


But I still get can not find symbol.  What is the issue ?

How to resolve it ?


Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Try replacing javax. with jakarta. in your imports
Avatar of cofactor
cofactor

ASKER

@CHEJ

What JAR do I require if I want to keep javax?

I am using java 11.0.17 2022-10-18 LTS

afaik, it's all going jakarta, so you don't want to. Did that work?

@CHEJ

afaik, it's all going jakarta, so you don't want to. Did that work?


It did not work

ServietException

Open in new window

should read

ServletException

Open in new window

It's just a typo ;-)


This has nothing (yet) to do with the transition from javax to jakarta, especially not for Apache 8.5!

It's just a typo ;-)

Hehe. Well spotted!

Apache Tomcat based on Jakarta will come with version Tomcat 10.1.2!

Yes, I thought the version was a little early for jakarta. That's why I said "try" ;)

@Alex [***Alex140181***] 

It's just a typo


Yes. Its working now. Thanks


How did you catch it ? are you using IDE ?


I am using a Notepad only. I could not catch it even after reading couple of times !! Do you have any suggestion how to avoid such silly mistakes ?

ASKER CERTIFIED SOLUTION
Avatar of Alex [***Alex140181***]
Alex [***Alex140181***]
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial