Results 1 to 6 of 6
  1. #1
    MissyMadi is offline Member
    Join Date
    Nov 2008
    Posts
    4
    Rep Power
    0

    Default java:34:cannot find symbol

    Hi,

    I trying to compile a java file but get the following error:
    SimpComp.java:34:cannot find symbol.

    I believe it has something to do with my classpaths. I don't really understand this yet, being new to java. This is what I've done so far:

    Using: Coco Compiler, Java, and JGrasp

    Setup:
    1. Java Classpath I created an environment variable, Classpath= C:\Program Files\Java\jdk1.6.0_07\bin
    2. Coco I created an environment variable, CocoJTHome=C:\Coco
    3. I commented out the package //package SimpComp; I think this may be where the problem is coming from because the class files are not being found.

    I am writing a compiler in Coco and using jGrasp to check the SimpComp.atg file - and this will parse correctly. I compiled all of the .java files to create class files.

    When I try to execute a java file SimpComp.java file I get the following error:
    SimpComp.java:34:cannot find symbol - there are 10 errors listed.

    How do I fix this error? How do I set up the classfiles to be found? I attached all of the files.

    Thanks!! MissyMadi
    Attached Files Attached Files

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,412
    Rep Power
    25

    Default

    SimpComp.java:34:cannot find symbol.
    Please always post the full text of the error message.
    What is on line 34?

  3. #3
    MissyMadi is offline Member
    Join Date
    Nov 2008
    Posts
    4
    Rep Power
    0

    Default Cannot Find Symbol

    C:\Coco\CocoJT\SimpCompCodeGen>javac SimpComp.java
    SimpComp.java:30: cannot find symbol
    symbol: variable Scanner
    location: class SimpComp
    Scanner.Init(inputName);

    SimpComp.java:31: cannot find symbol
    symbol: variable Errors
    location: class SimpComp
    Errors.Init(inputName, dir, mergeErrors);

    SimpComp.java:33: cannot find symbol
    symbol: variable Parser
    location: class SimpComp
    Parser.symTab=new SymbolTable();

    ....

    SimpComp.java:39: package Parser does not exist
    Parser.symTab.PrintTable();



    Zipped Word file attached with a print screen capture with full error list.
    Attached Files Attached Files

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,412
    Rep Power
    25

    Default

    Where are the symbols: Scanner, Errors and Parser defined?
    If they are classes you are referencing, you need to find what package they are in and add import statements for them.
    Look in the Java API doc for each of Sun's classes to find the package for that class.
    For the other symbols/class references, why are you using them if you don't know what they are or where they come from?

  5. #5
    MissyMadi is offline Member
    Join Date
    Nov 2008
    Posts
    4
    Rep Power
    0

    Default Java Classes

    The Parser, Scanner and Errors are defined in the SymbolTypes.java and SymbolTypes class files.

    The question I have is where and how do I reference the class files so that when I compile the Scanner.java, Parser.java and SimpComp.java files the classes can be found. The Parser.java file is looking for symbols which are located in the SymbolTable.java file.

    This project is from a class I'm taking and we were instructed to comment out the package //package SimpComp; because the class files would have the wrong path. But I'm not sure where to go from there. Where do I reference the class files.

    I am new to Java and I find the paths to the class files setup confusing. Could you give me some examples?

    Thanks, MissyMadi

  6. #6
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,412
    Rep Power
    25

    Default

    If you are not going to use packages, comment out the package statements in ALL of your source files and also comment out any import statements that refer to those packages. Put all of your source in the same folder and the compiler should find them when it needs them. You can compile the utility classes first then the main class. Or do a javac *.java to compile them all.

Similar Threads

  1. Replies: 9
    Last Post: 10-18-2008, 08:26 PM
  2. 'Cannot find symbol' error
    By minihazard10 in forum New To Java
    Replies: 6
    Last Post: 10-10-2008, 04:05 AM
  3. Replies: 3
    Last Post: 05-01-2008, 08:30 AM
  4. [SOLVED] Java Error: Cannot find Symbol...
    By bobleny in forum New To Java
    Replies: 8
    Last Post: 04-15-2008, 06:35 AM
  5. Error: cannot find symbol
    By cachi in forum AWT / Swing
    Replies: 1
    Last Post: 08-06-2007, 08: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
  •