This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Servlet 4b building problem

 
Carol Murphy
village idiot
Bartender
Posts: 1203
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9067
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where exactly did you put the old file? Where is build.xml?
 
Carol Murphy
village idiot
Bartender
Posts: 1203
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9067
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1203
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9067
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1203
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic