Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HFSJ: Error while compiling servlet example

 
Patrick Beck
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I am currently studying for SCWCD and tried to compile the example on page 176 (the listener test).

I created the java files and first compiled the Dog.java file with



Works fine, Dog.class was created in classes/com/example.

Now I tried to compile src/com/example/MyServletContextListener.java out of the WEB-INF directory with



and I get the following error:



Don't know why Dog class is not found, it is in the same directory.
I think I am just missing sth but I cannot figure out what?

Any ideas?

Thank you!
 
Dagbj�rn Nogva
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Patrick,

You need to add the classes directory to the -classpath on the javac command line, otherwise the compiler won't find Dogs.class when compiling MyServletContextListener.java.

Cheers,
Dagbj�rn
 
Patrick Beck
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your help, I tried to concatenate the path to the Dog.class to the classpath, seperated with a semicolon.



The following result:


Well, I do have sufficient access rights.

But then I tried to compile a bunch of java files with "javac ... *java" and now it works.

All 3 files have been compiled and moved to the classes dir.

Don't know what the reason was, but now it works

But thanks for your help!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic