aspose file tools*
The moose likes Beginning Java and the fly likes Problem with Chapter 5 - SimpleDotCom Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Problem with Chapter 5 - SimpleDotCom" Watch "Problem with Chapter 5 - SimpleDotCom" New topic
Author

Problem with Chapter 5 - SimpleDotCom

Robert Robles
Greenhorn

Joined: Sep 19, 2008
Posts: 4
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 ]
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 19059
    
  40

A couple of questions. (1) what is your class path set to? (2) how are you compiling the code? Including the directory that you are in, and the directory of the file.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Robert Robles
Greenhorn

Joined: Sep 19, 2008
Posts: 4
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.

Is there something I am doing wrong?

Thanks for your response!
aleem khan
Ranch Hand

Joined: Aug 07, 2008
Posts: 94
Your compiled SimpleDotcom.class file should be present where you have defined CLASSPATH . In this case SimpleDotcom.class should be present inside the bin of your jdk


SCJP(1.4), SCWCD, Oracle 9i SQL certified, Oracle PLSQL Developer Certified Associate
Robert Robles
Greenhorn

Joined: Sep 19, 2008
Posts: 4
I copied the class file to the bin directory and it compiled. I guess I was confused since all my other compilations ran fine without having to do this step. Thank you all for your help this worked.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 40029
    
  28
Two mistakes, I am afraid, Aleem Khan:
  • 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.
    Campbell Ritchie
    Sheriff

    Joined: Oct 13, 2005
    Posts: 40029
        
      28
    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.
    Robert Robles
    Greenhorn

    Joined: Sep 19, 2008
    Posts: 4
    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.
    Campbell Ritchie
    Sheriff

    Joined: Oct 13, 2005
    Posts: 40029
        
      28
    It's not a stupid question.
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: Problem with Chapter 5 - SimpleDotCom