DOM compilation problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Agathamk
    New Member
    • Feb 2008
    • 1

    #1

    DOM compilation problem

    HI IM a new beginner for working with java /xml and i have a project in which I need to use the dom4j tool to read my xml file. But for some reason i keep getting a compilation error whenever i put the import codes is:

    import org.dom4j.Docum ent;
    import org.dom4j.Docum entException;
    import org.dom4j.Eleme nt;
    import org.dom4j.Docum entHelper;
    import org.dom4j.io.SA XReader;
    import org.dom4j.io.XM LWriter;
    import org.dom4j.io.Ou tputFormat;

    it tells me that the the package on the dom4j file does not exist.... I saved my dom4j-1.6.1. download in the same project file as the java document..... does anyone know why I am getting an error?! I really need to get started on this project and this is really the easiest step i need to do and it's driving me crayy!

    Thanks for the help!
  • JosAH
    Recognized Expert MVP
    • Mar 2007
    • 11453

    #2
    Do you know what a 'classpath' variable is? It's a variable that lists zero or more
    directories and .jar files that your compiler can use as resources when it compiles
    a .java file. Suppose you stored your .jar file as:

    c:\foo\bar\your jarfile.jar

    you should compile your java file as follows:

    java -classpath c:\foo\bar\your jarfile.jar yourjavafile.ja va

    The '-classpath' flag tells your compiler where to search for all the imported stuff.

    kind regards,

    Jos

    Comment

    Working...