Error: cannot resolve symbol
I have that error and I don't know what else I can try.
The situation is the following:
'PuntoI.java' is an interface.
'Punto.java' is a class.
'Punto2Di.java' pretends to be an implementation of 'PuntoI.java'
--jGRASP exec: javac -g D:\Universidad\2_Edi\2005-2006\PrJAVA\Punto2Di.java
Punto2Di.java:13: cannot resolve symbol
symbol : class PuntoI
location: class estructuras.Punto2Di
public class Punto2Di implements PuntoI
^
Punto2Di.java:22: cannot resolve symbol
symbol : class Punto
location: class estructuras.Punto2Di
public Punto construir(double X, double Y)
Any idea of the solution?
Thank you very very much for your attention and help.
[819 byte] By [
Atreo] at [2007-11-11 7:51:43]

# 1 Re: Error: cannot resolve symbol
Are they in seperate packages (directories)? This looks like a failure to import the package PuntoI and Punto are in.
Similarly, it could be a classpath issue.
Laszlo at 2007-11-11 22:37:07 >

# 2 Re: Error: cannot resolve symbol
Hi Laszlo, thanks a lot for your answer!
Maybe it's due to in 'Punto2Di' (the one than implements 'PuntoI') I've writen import Punto.
'Punto' (it's a class), 'PuntoI' (interface) 'Punto2Di' (implementation) have in the first line this sentence:
package structures;
In the folder I only have these files:
'Punto.java' (and 'Punto.class')
'PuntoI.java' (and 'Punto.class')
'Punto2Di.java'
Should I write: 'import structures.PuntoI' ?
Has my error anthing to do with that?
Thanks for your help :WAVE:
Atreo at 2007-11-11 22:38:07 >

# 3 Re: Error: cannot resolve symbol
Since they're all in the same package, they need to be in the same directory, but it sounds like you've got that much correct.
That directory needs to have same name as the package. Make sure the directory and package name match.
Then make sure your classpath (either the CLASSPATH environment variable, or in the -classpath parameter) includes the parent directory of that directory.
So if your files are in, for example, the C:\myjava\estructures directory, make sure your classpath includes C:\myjava and your package declarations are all "package estructures;"
Laszlo at 2007-11-11 22:39:11 >

# 4 Re: Error: cannot resolve symbol
Hi again Laszlo!!
I think I've done some progress...
I've writen the class 'Punto' and the interface 'PuntoI' inside a file called 'estructuras.java'.
When I compile two files are generated: 'Punto.class' and 'PuntoI.class'.
But I'm still trying with my other friend 'Punto2Di.java'. It doesn't compile due to this:
Punto2Di.java:1: package estructuras does not exist
import estructuras.*;
^
Punto2Di.java:13: cannot access PuntoI
bad class file: .\PuntoI.class
class file contains wrong class: estructuras.PuntoI
I have another change to tell. Now the folder where these files are is called as the package 'estructuras'.
Maybe the error is because I have to include the package somewhere or I have to specify by the CLASSPATH or PATH variables.
I'm still very very new to these parameters and variables, but I'm trying...
Am I right?
Any suggestion?
Thank you very much for your help it's being great.
Atreo at 2007-11-11 22:40:10 >

# 5 Re: Error: cannot resolve symbol
Sorry, I haven't written al the lines the compiler shows me about the error.
Here they are:
--jGRASP exec: javac -g D:\Universidad\2_Edi\2005-2006\estructuras\Punto2Di.java
Punto2Di.java:1: package estructuras does not exist
import estructuras.PuntoI;
^
Punto2Di.java:13: cannot access PuntoI
bad class file: .\PuntoI.class
class file contains wrong class: estructuras.PuntoI
Please remove or make sure it appears in the correct subdirectory of the classpath.
public class Punto2Di implements PuntoI
^
2 errors
Help me please.
Thanks a lot
Atreo at 2007-11-11 22:41:14 >

# 6 Re: Error: cannot resolve symbol
Make sure your classpath includes D:\Universidad\2_Edi\2005-2006\ I dont' know jGRASP at all, so I can't tell you how to check or fix its classpath settings.
Rebuild all the .java files. Make sure all the package names are exactly correct. And make sure you have only one "public class ..." in each .java file.
I've never run into a "class file contains wrong class" message before. Strange.
Laszlo at 2007-11-11 22:42:19 >

# 7 Re: Error: cannot resolve symbol
Hello again :WAVE:
I've done changes following your suggestions.
I have a folder called 'estructuras' which has three files:
Punto.java
PuntoI.java (interface)
Punto2Di.java (implementation)
When I compile 'Punto2Di.java' outside 'estructuras' folder:
--jGRASP exec: javac -g D:\Universidad\2_Edi\2005-2006\Punto2Di.java
Punto2Di.java:13: cannot access estructuras.PuntoI
bad class file: .\estructuras\PuntoI.class
class file contains wrong class: PuntoI
Please remove or make sure it appears in the correct subdirectory of the classpath.
public class Punto2Di implements PuntoI
^
1 error
--jGRASP wedge2: exit code for process is 1.
--jGRASP: operation complete.
And when I compile 'Punto2Di.java' inside 'estructuras' folder:
--jGRASP exec: javac -g D:\Universidad\2_Edi\2005-2006\estructuras\Punto2Di.java
Punto2Di.java:1: package estructuras does not exist
import estructuras.*;
^
Punto2Di.java:13: Punto2Di is not abstract and does not override abstract method Distancia(PuntoI) in PuntoI
public class Punto2Di implements PuntoI
^
Punto2Di.java:22: construir(double,double) in Punto2Di cannot implement construir(double,double) in PuntoI; attempting to use incompatible return type
found : Punto
required: void
public Punto construir(double X, double Y)
^
Punto2Di.java:24: cannot resolve symbol
symbol : method Punto (double,double)
location: class Punto2Di
Punto(X,Y);
^
Punto2Di.java:47: cannot resolve symbol
symbol : method Abcisa ()
location: class Punto
distancia = ( Math.pow((abcisa - puntoAux.Abcisa()),2)
^
Punto2Di.java:48: cannot resolve symbol
symbol : method Ordenada ()
location: class Punto
+ Math.pow((ordenada - puntoAux.Ordenada()),2) );
^
6 errors
--jGRASP wedge2: exit code for process is 1.
--jGRASP: operation complete.
Long ago I tried to set my PATH and CLASSPATH for compiling from the command line wherever in my hard disk. As I didn't achieve it I downloaded jGrasp because I can compile files in other folders than ...\bin
Thanks a lot. :D
Atreo at 2007-11-11 22:43:12 >

# 8 Re: Error: cannot resolve symbol
> class file contains wrong class: PuntoI
It looks like something is wrong with the PuntoI.class file. Delete PuntoI.class, make sure its package and class definitions are set correctly, and recompile PuntoI.java.
The classpath must be set correctly. I don't know from XP, but here (http://faculty.ed.umuc.edu/~arnoldyl/NetBeansTutorials/Setting-Classpath.html) is a link to an XP classpath tutorial that says it works with jGRASP.
Packages can seem strange, but if they're not set right, or your classpath isn't correct, you're "hosed".
Laszlo at 2007-11-11 22:44:20 >
