• Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem in the compilation of the servlet using the classpath in the command line

 
Chidanand Chauhan
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can any one solve my problem in compilation of the servlet .

I am using the HFSJ and in the page 81 they have written the compilation of the java.
Please help me
I am using Tomcat 4.0

My deployment structure is c:\program files\Apache tomcat 4.0\

My development structure is c:\project\

how to compile the java file which is defined in the page 81 of HFSJ using classpath in the commandline

Please help me. I would appreciate it.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See:
http://faq.javaranch.com/view?CompilingServlets

If you haven't already, I would start by following some Java tutorials or by picking up a book on Java. Learning about the compiler, classpath issues, packages, inheritance, and all the other topics that require understanding will be a lot easier in the kind of simple command line applications found in those books/tutorials. Once you understand them, learning servlets will be a much easier and more pleasant experience.

Good Luck.
 
Alex George
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was having some problems with some of the examples in HFS&J.
I am able to compile but not able to see if after deploying it.
I guess the compilation problem will go away if you set classpath.
Before you compile it set classpath
>set CLASSPATH=C:/path.../Tomcat/common/lib/servlet-api.jar
Then compile it without the classpath parameter.

Let me know if it helps.
 
Chidanand Chauhan
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ben
I know core java quite well even i did servlet and jsp in weblogic but now i am shifting to Apache tomcat and not understanding the way it was written with the classpath.

if u understand the problem so kindly explain it
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Compiling your servlet code is no different than compiling any Java class.
It has some dependencies which are all contained in tomcat/common/lib/servlet-api.jar so you will need that library on your classpath.

For running, you don't set a classpath. Tomcat will ignore your classpath.
It looks for classes in a series of directories.
This is all explained here:
http://tomcat.apache.org/tomcat-5.5-doc/class-loader-howto.html

If you're already familiar with Java, then the documentation on the Tomcat site should be more than enough to get you up and running.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!