-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 } } 
3
  • @singhakash thanks for the link but no it is not a duplicate. Commented Apr 6, 2015 at 11:30
  • I tried your code and it worked for me?did you try the solution in the link Commented Apr 6, 2015 at 11:33
  • The solution in the link will not resolve my issue, I did look it up though. How come the codes worked for you, they are not working for me. Commented Apr 6, 2015 at 11:34

2 Answers 2

0

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

Sign up to request clarification or add additional context in comments.

1 Comment

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.
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 ?

7 Comments

I dont know how to check for this. And, I get this error while running and debugging.
if you are running using Eclipse this is a duplicate of stackoverflow.com/questions/9050504/…
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
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.
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.
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.