wood burning stoves 2.0*
The moose likes Ant, Maven and Other Build Tools and the fly likes Need help with ANT Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "Need help with ANT" Watch "Need help with ANT" New topic
Author

Need help with ANT

Bob Beerbower
Ranch Hand

Joined: Jun 06, 2001
Posts: 32
I'm trying to use ant to compile the source code that comes with Bruce Eckels Thinking in Java, but I'm running into some problems.



As you can see I'm getting an error that seems to say that the JDK cant be found. I've included echo of my ANT_HOME, JAVA_HOME, CLASSPATH, and PATH variables in case these provide some clues.

I have a functioning JDK (1.5) in C:\java\jdk, and ANT is in C:\java\ant

Any ideas what I'm doing wrong


Regards Bob Beerbower
Lewin Chan
Ranch Hand

Joined: Oct 10, 2001
Posts: 214
Bob,

There's nothing wrong with your environment. Rather something wrong with bruce-eckels assumptions about the versioning of java

I'm assuming you downloaded his TiJ 3rd Ed code exampels?

In the root build.xml (i.e. bruceeckel\build.xml) you will find the prepare task (I would list it here, but javaranch is moaning about the < being illegal), which compiles and runs CheckVersion.java

Basically, CheckVersion.java is a trifle faulty. You can probably work out what it is pretty quickly. (jdk5.0 reports java.version to be "1.5.0_03" on my installation, 1.4.2 as "1.4.2_08")

To resolve this you can just remove the tasks that execute and compiles CheckVersion (i.e. Deleting the javac and the java tasks)

Doing this will make it work with jdk5.0 (probably), although to be safe you should probably download jdk1.4.2_08, as his example code may use features that are considered "dangerous" by jdk5.0 and depending on his javac directives, they may fail to compile.

Lewin


I have no java certifications. This makes me a bad programmer. Ignore my post.
Bob Beerbower
Ranch Hand

Joined: Jun 06, 2001
Posts: 32
Lewin,
I got ANT working thanks to your help, by removing the

statement from the build target. I can now compile the files in the com/bruceeckel directory, and the chapter source code. I am still getting errors when I try to run the code. For example in chapter 5 when I try to run any of the class files I get the following error



So my ANT question has been answered, but judging by the above error do I still have a CLASSPATH problem?
[ May 25, 2005: Message edited by: Bob Beerbower ]
Carol Enderlin
drifter
Ranch Hand

Joined: Oct 10, 2000
Posts: 1364
I looked in the c05 directory/folder and there is no class cake, there IS a class Cake. Looks like java is trying to give you a hint with "(wrong name: Cake)"


Originally posted by Bob Beerbower:
Lewin,
I can now compile the files in the com/bruceeckel directory, and the chapter source code. I am still getting errors when I try to run the code. For example in chapter 5 when I try to run any of the class files I get the following error



So my ANT question has been answered, but judging by the above error do I still have a CLASSPATH problem?

[ May 25, 2005: Message edited by: Bob Beerbower ]


You said you were able build with ant, you can also run stuff.

e.g. using: ant Cake.run

FYI, if you check the build file you will see that the Cake.run target only runs Cake, it does not recompile.
Bob Beerbower
Ranch Hand

Joined: Jun 06, 2001
Posts: 32
Thanks,
I've let upper and lower case catch me up before. I need to learn to read exactly what the compiler is telling me, not what I think its telling me.I guess getting tripped up on the easy stuff is just part of learning.
[ May 27, 2005: Message edited by: Bob Beerbower ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Need help with ANT