Results 1 to 6 of 6

Thread: Error while compiling: javac= "cannot find symbol"

  1. #1
    Join Date
    Dec 2009
    Posts
    23

    Error while compiling: javac= "cannot find symbol"

    I am a intermediate programmer. I love to do programming in Java, and also knows other programming language like C sharp, SQL and Visual Basic. Recently i was doing programming in JAVA and came across one conflict i.e I have several Java files in a directory which is has been stored as a package at the start of the files. Package file manager:This program works correctly in an IDE, but problems occurs when compiling in command line. I have also set the classpath as i understand to be right for my computer to:[C:\Program Files\Java\jdk1.6.0_02\bin]. I can compile a class that references no other classes in this package/directory. But,files which reference other classes bring up such errors:
    javac AllFiles.java
    AllFiles.java:174: cannot find symbol
    symbol : variable Adam
    location : class filesmanager.AllFiles
    Adam.getItem(itemRef);
    Please tell me how to overcome this errors.

  2. #2
    Join Date
    Apr 2008
    Posts
    1,948

    Re: Error while compiling: javac= "cannot find symbol"

    According to my assumption that the files are in a directory named as 'filemanager' and if it is not, then files need to be in this directory. After this, you need to change to the directory that has 'filemanager' (so you would be at the root of the hierarchy). And from that point, now run:
    javac filemanager/AllFiles.java. (in command line)
    So that the path/destination of the source file relative/points to where you are compiling it (i.e filemanager/AllFiles.java) matches its fully-qualified name (filemanager.AllFiles). Hope your error will get fix.

  3. #3
    Join Date
    May 2008
    Posts
    2,012

    Re: Error while compiling: javac= "cannot find symbol"

    My knowledge about Java language says that, this would be case older version of .class files. In other words, maybe you can get yourself into a state where (.class) files comes from the older version of the source, but have no timestamps than the source. Thus, the compiler will see at the old or new class files and will not check the source code, and you will get an error like(i.e cannot find symbol) this do not make any sense based on the source. Now, delete every 'Allfiles.class' you can see and you also might have something hiding/hidden in strange places, so check nicely and then try to compile again. Hope your problem get fix.

  4. #4
    Join Date
    Apr 2008
    Posts
    2,005

    Re: Error while compiling: javac= "cannot find symbol"

    I am also the intermediate Java programmer. I studies about java says that when the cannot find symbol; symbol: variable(variable name) comes, is because the compiler has found the variable name that is not recognizable or the method call is missing the parenthesis. In order to overcome this error, check following points/clause:
    ->Did you done the declaration of the variable named in the message?
    ->Have you written the variable name correct( i.e with spelled exactly the same as you declared it) do check for typos, including capitalization. Remember that identifiers in the Java are case-senstive.
    ->Check that the method you are calling is with parenthesis for argument list or not? If not then make note that parentheses are required even if the method takes no arguments.

  5. #5
    Join Date
    May 2008
    Posts
    2,297

    Re: Error while compiling: javac= "cannot find symbol"

    My suggestion says that this is would be a incorrect classpath problem. Check that both of your compiled java files (i.e .class ) are in the correct classpath or in the directory where you calling the program? And also wpuld like to say that there is a environment variable which is called "CLASSPATH". This can be found by typing/writing 'set' in the command box if using Windows operating system. But maybe the classpath may differ/keep changing depended on the project, but can also set it manually before compiling and running the project.

  6. #6
    Join Date
    Nov 2005
    Posts
    1,323

    Re: Error while compiling: javac= "cannot find symbol"

    the error "cannot find symbol" comes when used a variable name that did not have been define. Maybe the forget ted the declaration. It can be also like you have declared it inside a block or loop and you trying to use it outside the block or loop. So, you should move the declaration to an encompassing outer block or loop that encloses all the references. Maybe it can be due to incorrect spell of the variable and slightly differently in declaration and reference. Always check the caps and double letters carefully. Hope this may fix your problem.

Similar Threads

  1. Replies: 2
    Last Post: 07-01-2012, 11:50 AM
  2. Replies: 6
    Last Post: 21-12-2011, 02:17 PM
  3. Replies: 5
    Last Post: 30-04-2011, 09:09 AM
  4. Replies: 3
    Last Post: 14-04-2009, 12:16 AM
  5. "On Click, Line 1: unexpected symbol near" error
    By Gopesh in forum Operating Systems
    Replies: 3
    Last Post: 10-03-2009, 05:41 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,751,719,956.07580 seconds with 16 queries