Results 1 to 7 of 7
Thread: Help with an error
- 02-04-2011, 04:40 PM #1
Member
- Join Date
- Jan 2011
- Posts
- 32
- Rep Power
- 0
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(); } } }
Thanks
-Sparky
- 02-04-2011, 05:25 PM #2
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 14,422
- Blog Entries
- 7
- Rep Power
- 28
- 02-04-2011, 11:42 PM #3
Member
- Join Date
- Jan 2011
- Posts
- 32
- Rep Power
- 0
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;
Java Code:public class Main { /** * @param args the command line arguments */ public static void main(String[] args) {
(I'm using NetBeans.)
- 02-05-2011, 12:01 AM #4
Moderator
- Join Date
- Feb 2009
- Location
- New Zealand
- Posts
- 4,716
- Rep Power
- 17
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.
- 02-05-2011, 04:47 AM #5
Member
- Join Date
- Jan 2011
- Posts
- 32
- Rep Power
- 0
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
- 02-05-2011, 06:03 AM #6
Moderator
- Join Date
- Feb 2009
- Location
- New Zealand
- Posts
- 4,716
- Rep Power
- 17
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?
- 02-05-2011, 06:23 AM #7
Member
- Join Date
- Jan 2011
- Posts
- 32
- Rep Power
- 0
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
-
java out of memory error-heap space error
By elsanthosh in forum NetBeansReplies: 4Last Post: 06-15-2010, 10:31 AM -
> Operator cannot be applied error and return incompatible types error
By corney_16 in forum New To JavaReplies: 1Last Post: 03-10-2010, 02:53 PM -
Thread: Error 500--Internal Server Error java.lang.NullPointerException
By jackdear44 in forum New To JavaReplies: 1Last Post: 12-05-2009, 08:28 AM -
java.lang.Error: Error opening DSound for capture
By NARs in forum NetworkingReplies: 1Last Post: 10-26-2009, 05:38 PM -
Diference Between compiler error Garbage collection and Runtime Error?
By makpandian in forum New To JavaReplies: 3Last Post: 01-23-2009, 09:53 AM
Bookmarks