Forums Register Login
Cannot resolve symbol
I am trying to compile hello.java that uses help.java and both of them are in the same directory. I can comile help but when I try to compile hello.java I get the following error message:
cannot resolve symbol
symbol : variable help
location: class hello
Your help is appreciated.
Well, you'd have to show us your "hello.java". If the compiler thinks "help" is a variable, then it's not a problem with finding help.class; it's a syntax problem.
Sorry for not including the code:

You have no class named "Help". You've got a file named Help.java, but it contains a class named "ServletUtilities". You can simply change "Help" to "ServletUtilities" to deal with the error.
The other problem here is that public classes are expected to be defined in a file named after them -- i.e., you should rename Help.java to ServletUtilities.java. Most likely you're already seeing a compiler warning about this.
I did change help.java to ServletUtilities.java and the reference in Hello.java. I still can not compile Hello java. I can compile ServletUtilities no problem. Since this two files are in the same folder it should not have been a problem.
Any idea why I can not compile Hello.java?
Well, if you made this change, the compiler error message would surely be different. What is the error message now?
Sorry I did not respond on time. The error message is as follows:
hello.java:12: cannot resolve symol
symbol : variable help
location: class Hello
out.println(help.headWithTitle(title) +
I can compile help with no problem. It is when I try to compile hello the above error message is issued.

You're almost there!
remember "help" != "Help" and it compiles
I must say thank you for trying to help me on this frustrating issue. I did change and now have the flowing code, which does give me the same error. I am not sure why. I did run the same code using BlueJ and it did compile no problem. I do not know why it does not compile when I do it at the command prompt. Any thoughts on this. I have not really used the command line very much. I am probably spoiled using BlueJ.

If you still get the same error message

hello.java:12: cannot resolve symbol
symbol : variable help
location: class Hello
out.println(help.headWithTitle(title) +

then perhaps you're compiling old source from the command line.
If you are using the CD command to get to the directory, then typing

, do a to check the timestamps and code
I still get the same error message. It does not make sense at all. I can compile Help but not Hello, because referece to Help. Both files are in the same directory. When I try to compile Hello, javac should have compile both automatically, because they are in the same folder.
When I use BlueJ no problem. It is only when I try to do it on a command line.
Thank you for you help.
This may well be a CLASSPATH issue. What is your CLASSPATH setting?
What happens when compiling with the following command?
javac -classpath . Hello.java
Thank you. You may be right to point out that it may be a CLASSPATH issue. I am getting package javax.servlet does not exist etc.
This is how I set-up my class path:

The two java programs I am trying to compile are in ...\webapps\ATS\WEB-INF\classes directory.
I am not sure whether my set-up is right.
What is not clear for me is that when I try to compile Help.java it does compile without an error. What is going on?
Goodbye moon men. Hello tiny ad:
Rocket Oven Kickstarter - from the trailboss

This thread has been viewed 2133 times.

All times above are in ranch (not your local) time.
The current ranch time is
Jul 16, 2018 18:15:24.