Java compilation error: "cannot resolve symbol"

P

Philipp Gressly

exquisitus said:
I have a simple test package that I am using to learn Java. I have two
files, both of which belong to the same package (mypackage). One of the
files uses a class defined in the other file. Both files are in the same
directory c:\temp\test\mypackage

I compiled the non-dependent file without any problem. However, when I
tried to compile the file that has a dependency to the other file, I got
a "cannot resolve symbol". I don't believe it!. The .class file from
the first compilation is right there (where on earth is the compiler
looking)?. I tried to spoonfed the compiler by typing the ff (from the
c:\temp\test\mypackage directory):

javac -c . foo2.java

and it still reported the same error !

This must be fairly easy to solve. I would appreciate any help. As an
aside, could anyone provide me with a simple build.xml file to build
this?. The two files are foo1.java and foo2.java. foo2.java has
adependency on foo1.java

Thanks

Try the following javac-command with the below mentioned classes
"Foo1.java" and "Foo2.java" (be aware of the package-declaration, the
upper- and lowercase Letters in the File- and Classnames and the
classpath and local directory:


cd C:\temp\test
javac -classpath . mypackage/*


File Foo1.java:package mypackage;

public class Foo1 {
Foo2 foo2;
}
<<<

File Foo2.javapackage mypackage;

public class Foo2 {
}
<<<

Hope that hepls
 
E

exquisitus

I have a simple test package that I am using to learn Java. I have two
files, both of which belong to the same package (mypackage). One of the
files uses a class defined in the other file. Both files are in the same
directory c:\temp\test\mypackage

I compiled the non-dependent file without any problem. However, when I
tried to compile the file that has a dependency to the other file, I got
a "cannot resolve symbol". I don't believe it!. The .class file from
the first compilation is right there (where on earth is the compiler
looking)?. I tried to spoonfed the compiler by typing the ff (from the
c:\temp\test\mypackage directory):

javac -c . foo2.java

and it still reported the same error !

This must be fairly easy to solve. I would appreciate any help. As an
aside, could anyone provide me with a simple build.xml file to build
this?. The two files are foo1.java and foo2.java. foo2.java has
adependency on foo1.java

Thanks
 
E

exquisitus

Philipp said:
Try the following javac-command with the below mentioned classes
"Foo1.java" and "Foo2.java" (be aware of the package-declaration, the
upper- and lowercase Letters in the File- and Classnames and the
classpath and local directory:





File Foo1.java:
package mypackage;

public class Foo1 {
Foo2 foo2;
}
<<<

File Foo2.java
package mypackage;

public class Foo2 {
}
<<<

Hope that hepls


Thank you very, very much - It worked !!!
 

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,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top