Results 1 to 5 of 5
  1. #1
    sashi799 is offline Member
    Join Date
    Jul 2010
    Posts
    15
    Rep Power
    0

    Default Error: Cannot find symbol during Importing package

    How can i solved the compile error: Cannot find symbol for the following codes

    symbol: class test2
    location: test.test3
    test2 aa = new test2();




    I'm trying to instantiate test2.java in test3.java

    Both the files are in C:\MyJavaProg\test

    My java path is set to C:\Program Files\Java\jdk1.6.0_06

    test2 code:
    Java Code:
    package test;
    
    public class test2 
    {
    	public String f()
    		{
    			return ("abcd");
    		}
    	
    }
    test3 code:
    Java Code:
    package test;
    import test.*;
    public class test3
    {
    	public static void main(String[] args) 
    	{
    		[b]test2 aa = new test2();[/b]
    		String bb = aa.f();
    			System.out.println(bb);
    	}
    }

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

    Default

    Does the classpath point to the folder containing the test (your package) folder?

  3. #3
    gafa's Avatar
    gafa is offline Senior Member
    Join Date
    Jun 2010
    Posts
    107
    Rep Power
    0

    Default

    you can put your test package right into your jdk bin folder :)

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

    Default

    you can put your test package right into your jdk bin folder
    NEVER.
    Keep all of your code outside of the JDK's folders

  5. #5
    sashi799 is offline Member
    Join Date
    Jul 2010
    Posts
    15
    Rep Power
    0

    Default

    Thanks Guys ...

    The issue was with CLASSPATH setting.

    This works:

    javac -cp c:\MyJavaProg\ test3.java

Similar Threads

  1. Cannot find symbol error
    By rajivjoshi in forum New To Java
    Replies: 3
    Last Post: 05-31-2010, 11:13 AM
  2. Replies: 9
    Last Post: 10-18-2008, 09:26 PM
  3. Replies: 3
    Last Post: 05-01-2008, 09:30 AM
  4. Error: cannot find symbol
    By silvia in forum New To Java
    Replies: 1
    Last Post: 08-07-2007, 06:39 AM
  5. Error: cannot find symbol
    By cachi in forum AWT / Swing
    Replies: 1
    Last Post: 08-06-2007, 09:12 PM

Posting Permissions

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