cannot resolve symbol

Discussion in 'Java' started by John Smith, Mar 2, 2006.

  1. John Smith

    John Smith Guest

    I tried:
    javac -verbose -g vvs.java

    and I got 24 errors of this type:
    vvs.java:275: cannot resolve symbol
    symbol : class Entry
    location: class com.dt.scenery.vvs
    Entry me = (Entry)VMapping.elementAt(iMappingIndex);
    ^

    but Entry.class is in the *same* directory as vvs.java.

    note:
    vvs.java belongs to
    package com.dt.scenery; (line 1 of vvs.java)

    and Entry.java belongs to
    package com.dt.scenery; (line 1 of Entry.java)

    Any suggestion for a fix is appreciated.
    John Smith, Mar 2, 2006
    #1
    1. Advertising

  2. John Smith

    zero Guest

    "John Smith" <> wrote in news:1141335221.030238.307960
    @i40g2000cwc.googlegroups.com:

    > I tried:
    > javac -verbose -g vvs.java
    >
    > and I got 24 errors of this type:
    > vvs.java:275: cannot resolve symbol
    > symbol : class Entry
    > location: class com.dt.scenery.vvs
    > Entry me = (Entry)VMapping.elementAt(iMappingIndex);
    > ^
    >
    > but Entry.class is in the *same* directory as vvs.java.
    >
    > note:
    > vvs.java belongs to
    > package com.dt.scenery; (line 1 of vvs.java)
    >
    > and Entry.java belongs to
    > package com.dt.scenery; (line 1 of Entry.java)
    >
    > Any suggestion for a fix is appreciated.
    >
    >


    Please follow the Java naming conventions. All classes should start
    with a capital letter, and use meaningful words. "vvs" is not a good
    classname. Following conventions will help you in the long run, trust
    me.

    You seem to have two problems here:

    1. javac doesn't automatically look for class files in the current
    directory. Instead, it looks on the classpath. Some people prefer to
    set the classpath in a system variable, but I find it easier to add it
    on the command line (for simple projects anyway) To specify the current
    directory, you use a dot, like this:

    javac -cp . vvs.java

    2. you're using packages, so instead of looking in the directory listed
    on the classpath, javac looks in a subdirectory thereof. In this case,
    it will look in a subdirectory called com/dt/scenery or com\dt\scenery,
    depending on your OS. Make sure the .class file is in this
    subdirectory. You can make javac place it there automatically when
    compiling, by using the -d option:

    javac -d . Entry.java

    Of course this only works if you have the source for Entry, and not just
    the class file.


    As a final note, I find it easier to compile all source files at once
    (again, in simple projects) since this eliminates possible dependency
    problems. I would typically use this command line:

    javac -cp .;somejar.jar -d . source/*.java
    zero, Mar 3, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. @lex-kid
    Replies:
    2
    Views:
    2,374
    @lex-kid
    Jul 7, 2003
  2. sufia
    Replies:
    1
    Views:
    3,022
    @lex-kid
    Jul 6, 2003
  3. Jo

    Cannot resolve symbol

    Jo, Apr 9, 2004, in forum: Java
    Replies:
    3
    Views:
    2,684
    Roedy Green
    Apr 10, 2004
  4. vivienne wykes
    Replies:
    4
    Views:
    902
    Roedy Green
    Jul 28, 2004
  5. Replies:
    1
    Views:
    10,107
Loading...

Share This Page