Runtime Error

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • indolent
    New Member
    • Sep 2006
    • 2

    Runtime Error

    this is my runtime error:
    java.lang.NoSuc hMethodError: Location: method <init>()V not found
    at driver.main(dri ver.java:5)

    this is my code for my first .java file:
    Code:
    public class driver
    {
        public static void main(String args[])
        {
            Location test = new Location();
            System.out.println(test.getX());
        }
    }
    this is my code for my second .java file:
    Code:
    public class Location
    {
    	private int x;
    	public Location()
    	{
    		x = 0;
    	}
    	public int getX()
    	{
    		return x;
    	}
    }
    other info:
    I am using BlueJ on WindowsXP.
    The java files are in the same folder with all the other files that are created with BlueJ.
  • PLA
    New Member
    • Aug 2006
    • 44

    #2
    Originally posted by indolent
    this is my runtime error:
    java.lang.NoSuc hMethodError: Location: method <init>()V not found
    at driver.main(dri ver.java:5)

    this is my code for my first .java file:
    Code:
    public class driver
    {
        public static void main(String args[])
        {
            Location test = new Location();
            System.out.println(test.getX());
        }
    }
    this is my code for my second .java file:
    Code:
    public class Location
    {
    	private int x;
    	public Location()
    	{
    		x = 0;
    	}
    	public int getX()
    	{
    		return x;
    	}
    }
    other info:
    I am using BlueJ on WindowsXP.
    The java files are in the same folder with all the other files that are created with BlueJ.
    It runs ok for me !

    Comment

    • indolent
      New Member
      • Sep 2006
      • 2

      #3
      Oh, about this.... I fixed it awhile back. The problem was that I was importing a .jar to my java files which had a predefined 'Location' class of its own. So when I ran my program, it was using the predefined class instead of mine and gave an error because I wasn't using the predefined Location's constructor properly. It was an easy fix when I just change my Location class name to something else not predefined. I hope this helps others who have this weird problem, for it took me too long to figure it out.

      Comment

      Working...