Note that there are some explanatory texts on larger screens.

plurals
  1. POcannot find symbol error while compiling a java class containing other class type object
    text
    copied!<p>I have a java package which contains two classes. Class A and Class B. I need to create an object of A type in class B. I don't know what is happening. Please someone help me out. </p> <p><strong>package pack;</strong></p> <p><strong>class A</strong></p> <p><strong>class B</strong></p> <p>I'm using JDK1.5 and tomcat and placed them in java folder in my D drive. </p> <p><strong>D:\java\jdk1.5</strong></p> <p><strong>D:\java\tomcat</strong></p> <p>Right now, my package folder is also in above location</p> <p><strong>D:\java\pack</strong></p> <p>Below is how i am compiling my java class files.</p> <p><strong>Step 1: Compiling A.java</strong> </p> <p>D:\Java\pack><strong>set path=D:\java\jdk1.5\bin</strong> (setting up path for jdk1.5 compiler)</p> <p>D:\Java\pack><strong>javac A.java</strong> (Successfuly compiled and formed <strong>A.class</strong>)</p> <p><strong>Step 1: Compiling B.java</strong></p> <p>D:\Java\pack><strong>javac B.java</strong> (here, i get an error message )</p> <p>Below is the ERROR message</p> <p><strong>Error Message</strong></p> <p><strong>D:\Java\pack>javac B.java</strong></p> <p><strong>B.java:9: cannot find symbol</strong></p> <p><strong>symbol : class A</strong></p> <p><strong>location: class pack.B</strong></p> <pre><code> A a = new A(); //creating an object of A type ^ </code></pre> <p><strong>B.java:9: cannot find symbol</strong></p> <p><strong>symbol : class A</strong></p> <p><strong>location: class pack.B</strong></p> <pre><code> A a = new A(); //creating an object of A type ^ </code></pre> <p><strong>2 errors</strong></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload