This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Java classes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Java classes" Watch "Java classes" New topic
Author

Java classes

steffy john
Greenhorn

Joined: Sep 07, 2001
Posts: 25
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

Joined: Sep 29, 2000
Posts: 8521
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;

"JavaRanch, where the deer and the Certified play" - David O'Meara
steffy john
Greenhorn

Joined: Sep 07, 2001
Posts: 25
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

Joined: Nov 22, 2008
Posts: 18944
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.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Java classes