| Author |
Unable to compile these java files
|
KRK Gowda
Ranch Hand
Joined: Nov 02, 2004
Posts: 132
|
|
i am new to java and i developed following code. i am not able to compile these files. i am getting error while compiling second file C:/Code/foo >javac Person.java C:/Code/foo >javac Employee.java Employee.java:2: cannot resolve symbol symbol : class Person location: class foo.Employee public class Employee extends Person ^ 1 error following are code Person.java package foo; public abstract class Person { private String name; public String getName() { return this.name;} public void setName(String name){ this.name=name; } } Employee.java package foo; public class Employee extends Person { private int empID; public int getEmpID() { return empID; } public void setEmpID(int empID) {this.empID=empID;} } settings set JAVA_HOME="C:\JDK1.4"; set CLASSPATH=".;C:\JDK1.4\LIB;C:\JDK1.4\LIB\TOOLS.JAR;C:\JDK1.4\BIN;"
|
 |
Sujatha Rangarajan
Greenhorn
Joined: Jul 19, 2006
Posts: 23
|
|
i think you have to include the import statement import foo.Person;
|
 |
Prabhakar Rao
Ranch Hand
Joined: Aug 23, 2006
Posts: 40
|
|
compile the files from C:\code like this. C:\Code>javac foo\Person.java C:\Code>javac foo\Employee.java Prabhakar
|
 |
Jesper de Jong
Java Cowboy
Bartender
Joined: Aug 16, 2005
Posts: 12952
|
|
Originally posted by Sujatha Rangarajan: i think you have to include the import statement import foo.Person;
No, that is not necessary, because both class Person and class Employee are in the same package foo. You don't need to import classes that are in the same package. Prabhakar's answer is right - you have to compile it from the directory C:\Code, not from C:\Code\foo.
|
Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
|
 |
Srinivas Kalvala
Ranch Hand
Joined: Oct 20, 2005
Posts: 257
|
|
Hello, you have set your classpath as, set CLASSPATH=".;C:\JDK1.4\LIB;C:\JDK1.4\LIB\TOOLS.JAR;C:\JDK1.4\BIN;" so do following , compile as javac -d . <classfile1> java -d . <classfile2> Make sure that classfile2 depending on classfile1. Happy compiling...
|
 |
KRK Gowda
Ranch Hand
Joined: Nov 02, 2004
Posts: 132
|
|
Thanks guys, it compiled Successfully
|
 |
DeepakKumar Srivastava
Greenhorn
Joined: Aug 19, 2006
Posts: 3
|
|
Originally posted by KRK Gowda: i am new to java and i developed following code. i am not able to compile these files. i am getting error while compiling second file C:/Code/foo >javac Person.java C:/Code/foo >javac Employee.java Employee.java:2: cannot resolve symbol symbol : class Person location: class foo.Employee public class Employee extends Person ^ 1 error following are code Person.java package foo; public abstract class Person { private String name; public String getName() { return this.name;} public void setName(String name){ this.name=name; } } Employee.java package foo; public class Employee extends Person { private int empID; public int getEmpID() { return empID; } public void setEmpID(int empID) {this.empID=empID;} } settings set JAVA_HOME="C:\JDK1.4"; set CLASSPATH=".;C:\JDK1.4\LIB;C:\JDK1.4\LIB\TOOLS.JAR;C:\JDK1.4\BIN;"
|
 |
DeepakKumar Srivastava
Greenhorn
Joined: Aug 19, 2006
Posts: 3
|
|
Originally posted by KRK Gowda: i am new to java and i developed following code. i am not able to compile these files. i am getting error while compiling second file C:/Code/foo >javac Person.java C:/Code/foo >javac Employee.java Employee.java:2: cannot resolve symbol symbol : class Person location: class foo.Employee public class Employee extends Person ^ 1 error following are code Person.java package foo; public abstract class Person { private String name; public String getName() { return this.name;} public void setName(String name){ this.name=name; } } Employee.java package foo; public class Employee extends Person { private int empID; public int getEmpID() { return empID; } public void setEmpID(int empID) {this.empID=empID;} } settings set JAVA_HOME="C:\JDK1.4"; set CLASSPATH=".;C:\JDK1.4\LIB;C:\JDK1.4\LIB\TOOLS.JAR;C:\JDK1.4\BIN;"
|
 |
DeepakKumar Srivastava
Greenhorn
Joined: Aug 19, 2006
Posts: 3
|
|
First of all you should comple the files like this javac -d . Person.java javac -d . Employee.java -d stands for directory and the'.' followed by it represents the path where the files are located to be compiled.So just go through the options and i m sure that it will work.
|
 |
 |
|
|
subject: Unable to compile these java files
|
|
|