wood burning stoves 2.0*
The moose likes Cattle Drive and the fly likes Servlet 4b building problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » This Site » Cattle Drive
Bookmark "Servlet 4b building problem" Watch "Servlet 4b building problem" New topic
Author

Servlet 4b building problem

Carol Murphy
village idiot
Bartender

Joined: Mar 15, 2001
Posts: 1194
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?

Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9044
    
  10
Where exactly did you put the old file? Where is build.xml?


JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
Carol Murphy
village idiot
Bartender

Joined: Mar 15, 2001
Posts: 1194
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
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9044
    
  10
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
??
Carol Murphy
village idiot
Bartender

Joined: Mar 15, 2001
Posts: 1194
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.
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9044
    
  10
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
src\java\com\javaranch\drive\videos
and one in
src\java\com\javaranch\drive\videos\4a

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.
Carol Murphy
village idiot
Bartender

Joined: Mar 15, 2001
Posts: 1194
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Servlet 4b building problem
 
Similar Threads
Ant for Servlets 3b - silly question
Need Servlets 4a Help
Could not compile JTidy (jtidy-04aug2000r7-src) with JDK1.6
Ant building error
Problem in building project using Ant build tool