-1

I am new to JAVA and this is my first attempt with inheritance. When I try to debug the below codes, I get the error: Source not found. I have no idea how to fix this. I created all of them under the same package.

If you guys need me to post more of my codes, please do let me know.

public class Agents {

  // The class has constructors and few variables

  }

public class User extends Agents {

  public User (){
    }

  public string name_user;

  public string assign_name_user(int j){
    name_user = "xr" + String.valueOf(j);
    }

 }

public class Comp extends Agents {
   public Comp (){
    }

  public string name_comp;

  public string assign_name_comp(int j){
    name_comp = "xr" + String.valueOf(j);
    }

 }
  }



  public class Comp_Behaviour extends Comp {

    // Variables and methods
    }

public class User_Behaviour extends User {

    // Variables and methods
    }

public class User_Solution extends User_Behaviour {

    // Variables and methods
    }

public class Process {
  public process (){}

  public static void main(String[] args){
    User_Solution solve = new User_Solution();
    int j = 1;
    solve.name_user = solve.assign_name_user( j); // ERROR: SOURCE NOT FOUND

    Comp_Behaviour behave = new Comp_Behaviour();
    behave.name_comp = behave.assign_name_comp(j);// ERROR: SOURCE NOT FOUND
    }
  }
Boris the Spider
  • 59,842
  • 6
  • 106
  • 166

2 Answers2

0

This often happens when you don't have your CLASSPATH properly defined. Did you put the current directory ('.') in your CLASSPATH?

Julia Gil
  • 9
  • 2
  • I didnt do anything manually. I believe I was very ignorant and naive in assuming that eclipse did everything. I will now google how to do what you suggested. – user3469181 Apr 06 '15 at 11:19
0

when do you get this error while compiling or running the program ? If compiling are you sure JDK is in use not just JRE ?

vasa.v03
  • 147
  • 2
  • 12
  • I dont know how to check for this. And, I get this error while running and debugging. – user3469181 Apr 06 '15 at 11:36
  • if you are running using Eclipse this is a duplicate of http://stackoverflow.com/questions/9050504/java-eclipse-error-source-not-found – vasa.v03 Apr 06 '15 at 11:47
  • I checked it and you are right JRE is in use at window->preferences->java->installed jres ...but I am unable to change this, if possible, can you please tell me how to do it – user3469181 Apr 06 '15 at 11:47
  • You should download JDK from Oracle official site and configure JAVA_HOME/PATH variables and restart Eclipse .. Since you are new to Java it will good to know that JRE packages libraries needed to run a java program . It is JDK which contains developer kit like compiler , visualvm , javadoc etc. – vasa.v03 Apr 06 '15 at 11:54
  • I already have JDK installed on my C drive in the programs folder. I have been trying to search the JAVA Home/Path Variables but no luck. – user3469181 Apr 06 '15 at 13:03
  • I am sorry for bugging you with this but I am really not able to configure the JAVA_Home path. I did control panel --- settings -- advanced setting---environment variable.. variable name(JAVA_Home) and Variable link:C:\Program Files (x86)\Java\jre7 But still I get the same error. – user3469181 Apr 06 '15 at 14:07
  • your JAVA_HOME should be C:\Program Files (x86)\Java not JRE and PATH=%JAVA_HOME%\bin – vasa.v03 Apr 07 '15 at 01:55