• Post Reply Bookmark Topic Watch Topic
  • New Topic

unable to compile servlet .java file  RSS feed

 
sahin sarkar
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
on my computer, i have configured the environment variables as

CATALINA_HOME : D:\apache-tomcat-8.0.9-windows-x64\apache-tomcat-8.0.9;
CLASSPATH : D:\apache-tomcat-8.0.9-windows-x64\apache-tomcat-8.0.9\lib\servlet-api.jar;D:\apache-tomcat-8.0.9-windows-x64\apache-tomcat-8.0.9\lib\jsp-api.jar;.;
JAVA_HOME : C:\Program Files\Java\jdk1.8.0_05
path : D:\apache-tomcat-8.0.9-windows-x64\apache-tomcat-8.0.9\bin

In reference to the book "Head First Servlets and JSP, 2nd edition", chapter-3(), page-81, the command to compile the servlet file to the desired location is

javac -classpath Users\bert\Applications2\tomcat\common\lib\servlet-api.jar:classes:. -d classes src/com/example/web/BeerSelect.java (from the Myprojects/beer-V1 directory)

wheras I have written

javac -classpath D:\apache-tomcat-8.0.9-windows-x64\apache-tomcat-8.0.9\lib\servlet-api.jar;classes;. -d classes src/com/example/web/BeerSelect.java (from the same directory as can be confirmed from the attachment of screenshot of error). this code is in accordance to the location of the respective files in my system, in particular the servlet-api.jar file.

After doing this, my computer is showing the error : file not found.

How do I resolve this?
Actually, I don't understand completely what this code is trying to accomplish. So please explain that also.

Thanks in advance
output.png
[Thumbnail for output.png]
error shown on running the command in cmd
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please do not post screenshots - copy & paste the error text instead.

Did you read and try to understand what the error message means? It's obvious - the Java compiler cannot find your source file named src/com/example/web/BeerSelect.java.

Make sure that the file exists and that you are in the correct current directory when you compile the file.

Do you actually have a file C:\Users\Sahin\Desktop\myprojects\beerV1\src\com\example\web\BeerSelect.java ?

Since you are doing this on Windows, use \ instead of / to separate elements in a path name.
 
sahin sarkar
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay, the problem is resolved.
Actually, there was a directory missing in the package hierarchy of the class. But I was too confident that I made the file in the right structure.

Thanks Jesper

 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!