1

I have made a class named Log in a file named Log.java.

Now, I am trying to instantiate an Object of class Log in another Class (lets say Trace.java), in main method (public static void main(String argv[])).

Whenever I try to execute follwing snippet, I get an error

Log l = new Log();

Error is :

error: cannot find symbol
    Log l = new Log();
    ^
8
  • 4
    Is Log in the same package? If not, you need to import it. Commented Oct 12, 2014 at 14:49
  • You're not executing the snippet. You're compiling the Trace class. How are you doing it? What are the packages of these two classes? Commented Oct 12, 2014 at 15:01
  • Yes @JBNizet, I apologies for mistake I am not using any IDE, I have defined Log.java and Trace.java in same directory and mentioned "package asgmnt;" in both the files. Commented Oct 12, 2014 at 15:01
  • So, what's the name of this directory, which commands are you executing, from which directory? Show us the tree of files/folders, and tell us what you're doing, precisely. Do that by editing your question. Commented Oct 12, 2014 at 15:05
  • Name of this directory is "asgmnt" and I have already compiled Log.java which was successful and I am getting above error, when I try to compile Trace.java using command javac "Trace.java" Commented Oct 12, 2014 at 15:07

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.