Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Compiling servlet with a helper class does't work

 
Petar Thomas
Ranch Hand
Posts: 234
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I can't compile a servlet if I try to instantiate some plain old Java class inside.

example:





C:\java\project1>javac -classpath c:\apache-tomcat-6.0.26\lib\servlet-api.jar;. - d classes c:\java\project1\src\foo\ServletTest.java


gives me an error described in the source code of the TestServlet.java


I have set variables JAVA_HOME, and CATALINA_HOME. I didn't set CLASSPATH, but when I set the CLASSPATH, nothing changes.

Once before I used a helper class, and then it compiled and worked, now it doesn't anymore.

I don't have any idea. Please , help me.
 
Ankit Garg
Sheriff
Posts: 9597
36
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you tell us where you put your Test.java file?? If it is in the c:\java\project1\src\foo\ directory, then use this command to compile your servlet

C:\java\project1\src>javac -classpath c:\apache-tomcat-6.0.26\lib\servlet-api.jar;. -d ..\classes foo\ServletTest.java
 
Petar Thomas
Ranch Hand
Posts: 234
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi! It is nice to see Your name again.

Thank You, that's it.

: )
 
Ankit Garg
Sheriff
Posts: 9597
36
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Petar Tomičić wrote:Hi! It is nice to see Your name again.

I don't remember changing my name at javaranch to anything else
 
Petar Thomas
Ranch Hand
Posts: 234
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
: ))

Few months ago I was for some time on SCJP forum, and I liked to read Your answers, and now it just made me happy to read again Your answer.
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!