Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

When compiling class not found

  Asked By: Erica    Date: Jan 27    Category: Java    Views: 792
  

I am trying to compile class B.java. And i am extending this class
with A. But it is giving me a error. I dont understand why it is
giving the error when both of them are defined in the same package.

I am mailing both of these java files....

A.java
------
package A;
public class A
{
public static void main(String args[])
{
System.out.println("I am in class A");
}
}

B.java
-----
package A;
public class B extends A
{
public static void main(String args[])
{
System.out.println("I am in class B");
}
}

Can anyone let me know what am i doing wrong.

Share: 

 

3 Answers Found

 
Answer #1    Answered By: Opal Alexander     Answered On: Jan 27

Could you import A package  into B file instead because
you already created a package A in A file? Or you
could create one of the two as a proxy class. Well,
just a thought.

 
Answer #2    Answered By: Coleman Smith     Answered On: Jan 27

The your problem is the CLASSPATH evironment variable
in your computer has not contained dot '.' in its
content.

YOU must set the CLASSPATH as follows:

set CLASSPATH=.;%CLASSPATH%

 
Answer #3    Answered By: Benny Torres     Answered On: Jan 27

I believe the problem lies in defining classpath variable which possibly
does not have package  A.
Set it accordingly it should work fine.

 
Didn't find what you were looking for? Find more on When compiling class not found Or get search suggestion and latest updates.




Tagged: