cannot resolve symbol

J

John Smith

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.
 
Z

zero

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top