This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
I have searched in the site and I can't find anyone with my issue. I cannot compile the following code:
I get the following error: C:\Java_Class\Game\SimpleDotComTestDrive.java:3: cannot find symbol symbol : class SimpleDotCom location: class SimpleDotComTestDrive SimpleDotCom dot = new SimpleDotCom(); ^ C:\Java_Class\Game\SimpleDotComTestDrive.java:3: cannot find symbol symbol : class SimpleDotCom location: class SimpleDotComTestDrive SimpleDotCom dot = new SimpleDotCom(); ^
The SimpleDotCom file is the following:
and this one compiles just fine. What am I missing? I have actually copied and fixed snippets of other peoples code posted here and I still get the same error message. Is is something in my environment? Everything up to this specific file has complied just fine.
Thanks in advance for your help!
[HENRY: Added Code Tags] [ September 19, 2008: Message edited by: Henry Wong ]
1) The class path is set too .;C:\Program Files\Java\jdk1.6.0_07\bin
2) I run the javac command from C:\Program Files\Java\jdk1.6.0_07\bin directory. the *.java files are in another directory so for example if I wanted to compile the SimpleDotCom.java code I type " javac C:\Java_Scripts\SimpleDotCom.java " and the files compile within that directory. I have done other code similar to this one in the same fashion without issues.
Your bin directory shouldn't be in your classpath at all; it should only be in your PATH.
You oughtn't to put your own files in the Java installation folders; leave them for what your installation provides.
You probably haven't got the two files in the same folder, and that is the problem. I presume you are not using any package declarations (the downloaded version will probably have package declarations in), so you should simply put both .java files in the same folder.
If you are using package declarations it becomes more complicated.
Joined: Oct 13, 2005
Originally posted by Henry Wong: . . . what is your class path set to?
Your classpath on Windows must contain a . which may appear as .; or ;. or ;.; and it doesn't seem to matter if it appears several times. The default Windows classpath already has a . in, so you should never need to change it. The . means "current directory," and you only have to specify a classpath when you need resources from a different folder. That is best done at the command line rather than an environment variable.
Joined: Sep 19, 2008
Although I thought I had set the CLASSPATH correctly, this happened to be the case. I have added the classpath of my working directory and everything is working fine. I am sorry for the stupid question, I'll try to research better next time.
Joined: Oct 13, 2005
It's not a stupid question.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com