Results 1 to 5 of 5
  1. #1
    Bahirji Naik is offline Member
    Join Date
    Dec 2011
    Posts
    5
    Rep Power
    0

    Post 'error: cannot find symbol' please help

    This may be stupid or old error but I search all threads and did all related task but still I have this problem 'error: cannot find symbol'

    Main class :


    package vilsoft.tree;

    import java.applet.*;
    import vilsoft.tree.*;
    import java.awt.Container;

    import javax.swing.*;

    public class Main extends JApplet{

    public void init()
    {
    Container content_pane = getContentPane ();

    // Create an instance of DrawingPanel
    int x=1000, y=1000;
    content_pane.setSize(x, y);

    Google amol=new Google();
    content_pane.add(amol);

    }

    public void paint(){

    }
    }


    Google class :



    package vilsoft.tree;

    import javax.swing.JPanel;

    public class Google extends JPanel{

    }


    I put both .java files in same folder i.e. in /vilsoft/tree. When I compile and run through Eclipse, there is no error but when I am running through 'javac' it showing :

    Main.java:19: error: cannot find symbol
    Google amol=new Google();
    ^
    symbol: class Google
    location: class Main
    Main.java:19: error: cannot find symbol
    Google amol=new Google();
    ^
    symbol: class Google
    location: class Main
    2 errors

    Please help me..

  2. #2
    quad64bit's Avatar
    quad64bit is offline Moderator
    Join Date
    Jul 2009
    Location
    VA
    Posts
    1,323
    Rep Power
    7

    Default Re: 'error: cannot find symbol' please help

    I have a feeling you're trying to compile from the wrong place. If your package is located at:
    /someFolder/vilsoft/tree/Main.java
    Then you need to cd to the someFolder dir to do the compile, not the tree folder:

    cd /someFolder
    javac vilsoft/tree/Main.java

    Javac always needs to run from the root of the package and it needs the complete path to the file to compile relative to the current directory. That should work!

  3. #3
    quad64bit's Avatar
    quad64bit is offline Moderator
    Join Date
    Jul 2009
    Location
    VA
    Posts
    1,323
    Rep Power
    7

    Default Re: 'error: cannot find symbol' please help

    FYI, you'll need to run it the same way too!

  4. #4
    Bahirji Naik is offline Member
    Join Date
    Dec 2011
    Posts
    5
    Rep Power
    0

    Default Re: 'error: cannot find symbol' please help

    Yes..U r right... Its working now !! Thanx quad !

  5. #5
    quad64bit's Avatar
    quad64bit is offline Moderator
    Join Date
    Jul 2009
    Location
    VA
    Posts
    1,323
    Rep Power
    7

    Default Re: 'error: cannot find symbol' please help

    No problem, glad I could help! Please mark the thread as solved if you don't mind :D

Similar Threads

  1. error: Cannot find symbol
    By iswan in forum AWT / Swing
    Replies: 3
    Last Post: 09-30-2011, 04:02 PM
  2. Cannot Find Symbol error
    By mrgreenacid in forum New To Java
    Replies: 13
    Last Post: 05-16-2011, 07:28 AM
  3. Cannot find symbol Error
    By new_Java in forum New To Java
    Replies: 3
    Last Post: 02-17-2011, 11:23 PM
  4. Replies: 9
    Last Post: 10-18-2008, 08:26 PM
  5. Error: cannot find symbol
    By cachi in forum AWT / Swing
    Replies: 1
    Last Post: 08-06-2007, 08:12 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •