Results 1 to 9 of 9
  1. #1
    JimmyD is offline Member
    Join Date
    Oct 2011
    Location
    New Jersey
    Posts
    44
    Rep Power
    0

    Default Strange "Cannot find symbol" error...

    I am getting a bizarre "cannot find symbol" error on compilation..

    I developed a set of my own util libraries as a package. let's say it's name packageA.

    The folder packageA sits in a dir say c:\java .

    the path c:\java is in my classpath environmental variable.

    Today I wrote a program that calls some static functions in one library file (Lib.java) in package A. So my code looks like this.

    This little program is called testLib.java, and say it sits in a folder z:\folderA

    ================================================== =
    Java Code:
    import packageA.*;
    
    public class testLib	{
    
    	public static void main(String[] args)
    	{
    		
    		if (!Lib.functionA("aaa"))
    		{
    			System.out.println("testLib :: functionA fails... ");
    		}
    		else
    		{		
    			AnyObject aa = null;
    			
    			try 
    			{
    				aa = new AnyObject("aaa");
    				
    			}
    			catch (Exception e)
    			{
    			        System.out.println("testLib :: exit...");
    				System.exit(-1);
    			}	
    			
    			
    			while (!aa.isEmpty())
    			{
    				
    				try
    				{
    					String temp = Lib.functionB(aa);					
    				
    				}
    				catch (Exception e)
    				{
    					System.out.println("functionB fails :: " + e);
    					e.printStackTrace();
    				}
    			
    			
    			}
    			
    			
    		
    		
    		}
    		
    	}
    	
    }
    ================================================== =

    The strange thing is : the only compilation error:
    Java Code:
    Z:\folderA>javac testLib.java
    testLib.java:40: cannot find symbol
    symbol  : method functionB(AnyObject)
    location: class packageA.Lib
                                       	       String temp = Lib.functionB(aa);					
                                                                         ^
    1 error
    ================================================== =

    That means function A is ok. I comment out the line involving functionB, the program compiles and runs correctly.

    Moreover, if I put this code in any other directory (i tried to put in a sub directory of folderA, or in parallel with folderA), both functionA, B are compiled, i mean the entire program compiles and runs correctly.

    That means, only in directory z:\folderA, function B is not identified.

    ================================================== =

    my first thought is there is a conflicting/duplicate class somewhere in (or near..?) folderA.. but I can't find any. And the spelling stuff are all correct. This has bugged me for an hour...
    Last edited by Norm; 04-19-2012 at 09:09 PM. Reason: added code tags

  2. #2
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,559
    Rep Power
    25

    Default Re: Strange "Cannot find symbol" error...

    Where is the method: functionB defined?
    If you don't understand my response, don't ignore it, ask a question.

  3. #3
    JimmyD is offline Member
    Join Date
    Oct 2011
    Location
    New Jersey
    Posts
    44
    Rep Power
    0

    Default Re: Strange "Cannot find symbol" error...

    both functionA and function B are defined in the Lib.java in package/folder packageA

  4. #4
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,559
    Rep Power
    25

    Default Re: Strange "Cannot find symbol" error...

    Can you post the code that shows their definitions?

    Why do you put a space in the name when posting the method name: function B? Do you mean a method named: B or ??
    If you don't understand my response, don't ignore it, ask a question.

  5. #5
    JimmyD is offline Member
    Join Date
    Oct 2011
    Location
    New Jersey
    Posts
    44
    Rep Power
    0

    Default Re: Strange "Cannot find symbol" error...

    sure.

    c:\java\packageA> more Lib.java

    ========================================

    Java Code:
    package packageA;
    
    import java.io.*;
    import java.text.*;
    import java.util.*;
    
    public class Lib {
    
    // ===============================================================
    // checking status
        
    public static boolean functionA(String aa)
    {
        return  (someboolean);
    }
    
    
    // ===============================================================
        
    public static String functionB(AnyObject a)
        {
            return (a string based on processing of object a);
        }
    
    
    }
    ============================

    P.S. Thank you Norm for formatting the codes for me.. How to format the code using the forum?
    Last edited by JimmyD; 04-19-2012 at 09:37 PM.

  6. #6
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,559
    Rep Power
    25

    Default Re: Strange "Cannot find symbol" error...

    BB Code List - Java Programming Forum
    Or press Go Advanced, select code, press # icon above the box

    Where does the Lib class get its definition of the AnyObject class? Is there more than one definition?
    If you don't understand my response, don't ignore it, ask a question.

  7. #7
    JimmyD is offline Member
    Join Date
    Oct 2011
    Location
    New Jersey
    Posts
    44
    Rep Power
    0

    Default Re: Strange "Cannot find symbol" error...

    wow Thank so much for the help Norm!

    Indeed, I have multiple copies of AnyObject.java.. one in the packageA folder, and one in z:\folderA.. I deleted the copies in z:\folderA, and everything is good.

  8. #8
    JimmyD is offline Member
    Join Date
    Oct 2011
    Location
    New Jersey
    Posts
    44
    Rep Power
    0

    Default Re: Strange "Cannot find symbol" error...

    aha~ and I got the codes part. Thanks again!

  9. #9
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,559
    Rep Power
    25

    Default Re: Strange "Cannot find symbol" error...

    Moved to New to Java. Not that advanced.
    If you don't understand my response, don't ignore it, ask a question.

Similar Threads

  1. "Cannot find symbol" error
    By MBD in forum New To Java
    Replies: 5
    Last Post: 09-27-2011, 02:41 PM
  2. "cannot find symbol" error
    By droidus in forum New To Java
    Replies: 2
    Last Post: 09-07-2011, 07:43 AM
  3. Replies: 5
    Last Post: 04-24-2011, 03:21 PM
  4. Error "can not find symbol variable"
    By FullMetalHollow in forum New To Java
    Replies: 5
    Last Post: 10-04-2009, 09:51 PM
  5. "Cannont find symbol Constructor" error
    By Welsh in forum New To Java
    Replies: 7
    Last Post: 01-25-2008, 12:12 AM

Posting Permissions

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