jQuery in Action, 3rd edition
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 Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Java classes" Watch "Java classes" New topic

Java classes

steffy john

Joined: Sep 07, 2001
Posts: 25
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 ?
Cindy Glass
"The Hood"

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.
set CLASSPATH=.;c:\jdk1.3.0\lib;c:\myApp\myClasses;

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

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.
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.
I agree. Here's the link: http://aspose.com/file-tools
subject: Java classes
It's not a secret anymore!