Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Java classes

 
steffy john
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Just a beginning question.
I have 2 java files , AAA.java and BBB.java.
class AAA{
public static void main(String[] args){

}
}
class BBB{
public static void main(String[] args){
AAA a = new AAA();
}
}
These 2 files exist in the C: prompt of my system. NOT in any packages.
But when I complie BBB, it is showing that class AAA not found.
Why is it so ?
I added import AAA, still it gives the same problem.
Cn anyone tell me what the problem is ?
PPlease consider it as a beginner's qn ?
Thanks,
Steff
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
java looks at the classpath parameter to find out where to go to locate other class files.
You need to revise (or create) your classpath to either include the c: directory or to include a dot as a directory which means "look in the current directory that I am in".
You can either set your classpath in the system environment panel, or by editing your autoexec.bat to include a classpath statement, or as I do - I just run a .bat file that sets the classpath to whatever I want it to be right then.
ex:
set CLASSPATH=.;c:\jdk1.3.0\lib;c:\myApp\myClasses;
 
steffy john
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Cindy, thanks a lot
I added a .; in the classpath and now the file is getting complied.
Thanks for your help.
Steff
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Another way is to let the class BBB inherit from AAA.
That is class BBB should be written in this form eg
class BBB extends AAA {
It will also not print out anything because there is no return method found.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic