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
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
posted
0
Thanks Cindy, thanks a lot I added a .; in the classpath and now the file is getting complied. Thanks for your help. Steff
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.