This week's giveaway is in the Java/Jakarta EE forum.
We're giving away four copies of Java EE 8 High Performance and have Romain Manni-Bucau on-line!
See ANT, at least try this out...

within WEB-INF have two directories...

all of my code is in the src directory, but there are no subfolders here. So even if my class is in a package, I don't worry about it for the source file.

I use Textpad as my java 'IDE', and my javac macro looks like:

-classpath c:\jars\servlet.jar;..\classes;%CLASSPATH% -d ..\classes $File

What this does is several things. First, you're absolutely specifying where to find servlet.jar. Then, you are also specifying where to find any of your own files (that's the ..\classes part). Why are they there? That's the second cool thing. The -d ..\classes option tells javac to transfer your compiled class files into the classes directory... and the added benefit is that it will put them in the appropriate folder heirarchy (into their packages).

How does this help you? If for example, you placed the source for both your bean and servlet class into the src directory, and compiled the bean class first, you'd find it appearing in classes\packagex\utility\bean.class

Then when your servlet tries to import it, it should find it, because you are sending it ..\classes with the -cp switch.

This has worked for me for quite a while. And from project to project, you don't need to change your settings in Textpad, as long as you always have a src and classes directory at the same level (and compile from the root of src)
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!