Results 1 to 7 of 7
  1. #1
    Sparky is offline Member
    Join Date
    Jan 2011
    Posts
    32
    Rep Power
    0

    Default Help with an error

    When I compile my code I get: "Build successful"

    When I click run (and then "run anyway due to it finding an error) I get:

    java.lang.ExceptionInInitializerError
    Caused by: java.lang.RuntimeException: Uncompilable source code - package org.jdom does not exist
    at v_meter.Main.<clinit>(Main.java:21)
    Could not find the main class: v_meter.Main. Program will exit.
    Exception in thread "main" Java Result: 1

    Here is my code:
    Java Code:
    package v_meter_xml;
    
    /**
     *
    
     */
    
    //import javax.xml.parsers.DocumentBuilder;
    //import javax.xml.parsers.DocumentBuilderFactory;
    
    import org.jdom.JDOMException;
    import org.jdom.input.SAXBuilder;
    import org.jdom.Document;
    import java.io.IOException;
    //import org.w3c.dom.Document;
    
    //import org.w3c.dom.Element;
    //import org.w3c.dom.Node;
    //import org.w3c.dom.NodeList;
    //import java.io.File;
    
    public class Main {
    
        /**
         * @param args the command line arguments
         */
        public static void main(String[] args) {
            // TODO code application logic here
    
            try{
    SAXBuilder parser = new SAXBuilder();
    Document doc = parser.build("http://developerlife.com/xmljavatutorial1/AddressBook.xml");
    
    
    
    
    
    
    
              
      } catch (Exception e) {
        e.printStackTrace();
      }
     }
      
    }
    What is the error telling me? How do I fix it?

    Thanks
    -Sparky

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,440
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by Sparky View Post
    Could not find the main class: v_meter.Main. Program will exit.
    Your program is complaining about not being able to find the v_meter.Main class; you're showing us a v_meter_xml.Main class; those two class have nothing to do with eachother.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  3. #3
    Sparky is offline Member
    Join Date
    Jan 2011
    Posts
    32
    Rep Power
    0

    Default

    Is this an error I fix within the program?

    I don't see within my program where I am refering to v_meter.Main.

    I have:
    Java Code:
    package v_meter_xml;
    and:
    Java Code:
    public class Main {
    
        /**
         * @param args the command line arguments
         */
        public static void main(String[] args) {
    The name of the project is:v_meter_xml

    (I'm using NetBeans.)

  4. #4
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,565
    Rep Power
    12

    Default

    Is this an error I fix within the program?
    ...
    (I'm using NetBeans.)

    There's nothing in the code you posted that refers to v_meter.Main, but look at the error message:

    Java Code:
    java.lang.ExceptionInInitializerError
    Caused by: java.lang.RuntimeException: Uncompilable source code - package org.jdom does not exist
    at v_meter.Main.<clinit>(Main.java:21)
    Could not find the main class: v_meter.Main. Program will exit.
    Exception in thread "main" Java Result: 1

    It looks like the configuration of your project is such that NB interpreted your click as "run v_meter.Main" (hence the could not find main class message) So, to directly answer your question: it may be nothing wrong within the code, but rather how you compile and run it.

    Perhaps you should deal with the first error - the one you didn't post - as that may give more clues.

    ----------------------

    As a general tip, I would consider "clean and rebuild" and also looking at the program configuration to make sure it all looks good.

  5. #5
    Sparky is offline Member
    Join Date
    Jan 2011
    Posts
    32
    Rep Power
    0

    Default

    I don't understand.

    When I compile it, I get no errors.

    When I run it - it stops and reads that it has encountered a problem, when I click "run anyway" I get the text that I posted in the first post.

    What other error do you see that I need to pursue?

    Thanks
    -Sparky

  6. #6
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,565
    Rep Power
    12

    Default

    Is that all it says: "encountered a problem"?

    The runtime error you posted - "Could not find the main class: v_meter.Main" - shows that what you are attempting to run is v_meter.Main.

    Are you using an IDE? Which?

  7. #7
    Sparky is offline Member
    Join Date
    Jan 2011
    Posts
    32
    Rep Power
    0

    Default

    I cut and pasted the error - as far as I know that's everything reported/

    I will not be behind the computer that has that project until Monday to attempt anymore on that problem.

    I'm tempted to start over - I feel like that will do it because it's something stupid on my part - I just didn't see it and as a learning exercise I want to see what I did wrong.

Similar Threads

  1. java out of memory error-heap space error
    By elsanthosh in forum NetBeans
    Replies: 4
    Last Post: 06-15-2010, 09:31 AM
  2. Replies: 1
    Last Post: 03-10-2010, 01:53 PM
  3. Replies: 1
    Last Post: 12-05-2009, 07:28 AM
  4. Replies: 1
    Last Post: 10-26-2009, 04:38 PM
  5. Replies: 3
    Last Post: 01-23-2009, 08:53 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •