I have an A.java class which uses B.java class as an object.
When I compile A.java class, it throws a compile error message, since the Java compiler can not reference the B.java object at all. So, here is my question:
How do I compile A.java class if it includes another B.java class?
Eclipse is a great tool, but this tool is not useful when I need to compile a Java file for Java beans.
You haven’t explained how you’re trying to compile A.java, or whether you’ve already compiled B.java. If you haven’t compiled either of them yet, just compile them both together, e.g.
If you’ve already compiled B, you need to make sure you’ve got the classpath right, e.g.
Note that the classpath value shouldn’t be the B.class file itself, nor even the directory containing B.class – but the root of the output hierarchy. So if B is in package foo.bar, and B.class is in directory /x/y/z/foo/bar you’d write: