Forums Register Login
Servlet 4b building problem
I copied the instructor's solution for Servlets 4b and then tried to do a build. Got the following complaint from the compiler about a duplicate class. The code compiles okay, and the source file for Servlets 4a which goes by the same name has been put into its own directory inside videos in case I need to look at it again. So where is this duplicate file?

Where exactly did you put the old file? Where is build.xml?
build.xml is at C:\Program Files\Java\videos, which is where it was for the 4a assignment. I put the source code for Servlet 4a in a directory named 4a in com/javaranch/drive/videos/4a
I figured if it was in its own directory, it wouldn't cause problems
I'm kinda confused.
You have 4a here
C:\Program Files\Java\videos\com\javaranch\drive\videos\4a\src\java\com\javaranch\drive\videos\VideoServlet.java
and 4b here
C:\Program Files\Java\videos\com\javaranch\drive\videos\src\java\com\javaranch\drive\videos\VideoServlet.java
this is the directory structure:

C:\Program Files\Java\videos\src\java\com\javaranch\drive\videos

I put the source file for 4b inside the last directory, and created a directory named 4a inside the last videos directory. This is where I put the source code for 4a

Basically all I did was replace the source code for 4a with the code for 4b, and move 4a to its own directory in case I needed it for some reason.
Notice in the build.xml that ant uses -- the compile target -- this line:
<javac srcdir='${src.dir}/java' destdir='${classes.dir}'>

This tells ant that any file that ends with .java in any subdirectory of the ${src.dir}/java directory, which, in this case, is
C:\Program Files\Java\videos\src\java\
gets compiled.

If I understand correctly, you have two files named VideoServlet inside that subdirectory, one in
and one in

You'll need to keep them further apart than that ... maybe put one in src4a\java\com\javaranch\drive\videos.

Since ant takes the src\java path, it will ignore anything in the the src4a\java path.
Aha! I had an intuition it was because of that, but I didn't want to fix it and not know the reason why it was fixed!
Thanks, I learned something today.
Without deviation from the norm, progress is not possible - Zappa. Tiny ad:
Rocket Oven Kickstarter - from the trailboss

This thread has been viewed 1005 times.

All times above are in ranch (not your local) time.
The current ranch time is
Jul 16, 2018 00:59:05.