File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Error when using JDOM Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Error when using JDOM" Watch "Error when using JDOM" New topic
Author

Error when using JDOM

Sujai Kaarthik
Ranch Hand

Joined: Dec 29, 2008
Posts: 162
Ant sample

codes

Hi everyone,
I was trying to compile the codes in the above link through Ant. I followed the steps as shown in the first URL.
Once I run the build file, I get the following error in the code:



Even when I try to compile it through ordinary javac method, it yells the same error. I have placed the jdom.jar in jdk\jre\lib. I think that is not the problem. What would be the problem?


I think this error is in actual code only. So I post this here instead of posting in ANT forum


The greater danger for most of us is not that our aim is too high and we miss it, but that it is too low and we reach it
Sujai Kaarthik
Ranch Hand

Joined: Dec 29, 2008
Posts: 162
The full code is


Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14272
    
  21

Sujai Kaarthik wrote:I have placed the jdom.jar in jdk\jre\lib. I think that is not the problem. What would be the problem?

Putting JAR files there is not a good idea. Just add the JAR file to your classpath, by setting the CLASSPATH environment variable appropriately or by using the -cp or -classpath command line switches with the javac / java commands. See How To Set The Classpath.

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
Sujai Kaarthik
Ranch Hand

Joined: Dec 29, 2008
Posts: 162
It still produces the same error Jesper
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42289
    
  64
The error message states that the class "JDOMUtils" can't be found. That makes sense, because it's not in any of the packages that get imported. You'll need to add an import statement for it.


Ping & DNS - my free Android networking tools app
Sujai Kaarthik
Ranch Hand

Joined: Dec 29, 2008
Posts: 162
Thanks Ulf for your reply..

But, the JDOMUtils class must be in the downloaded JAR, but that is not present there!!

what shall I do now?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42289
    
  64
What is "the downloaded jar"? No class of that name exists in the JDOM API, so where did you see it being used?
Sujai Kaarthik
Ranch Hand

Joined: Dec 29, 2008
Posts: 162
I actually tried to integrate JUnit with Ant. So, I googled and found a links that I have posted in my first post. The actual code, the build file and the JUnit test codes were all from that link. When I tried to compile those codes as said in that first link, the error message said me to include JDOM-b9 JAR.

After you replied to me, I guessed that JDOMUtils class must lie in JDOM-b9 JAR. So I explored through the JAR to find such a class (but in vein).

Actually I didn't saw any program using JDOMUtils. Its just a plain guess because of the word JDOM

I took that code out, and used the moneysample example from JUnit instead and made some alteration to the build file. Yes, I was successful in this attempt.

Ulf, by the way thank you very much for your help
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Error when using JDOM