File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Cannot find symbol Error 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 "Cannot find symbol Error" Watch "Cannot find symbol Error" New topic
Author

Cannot find symbol Error

syruss kumar
Ranch Hand

Joined: Jul 23, 2009
Posts: 97
Hi all,

I have created a simple application in java swings .It contain 2 classes
1.Clock.java 2.ClockFRame.java both are in same package
my path variable is C:\Program Files\Java\jdk1.5.0_14\bin

When im tring to compile from command prompt i got this error

D:\TestExe\com\calender>javac ClockFrame.java
ClockFrame.java:11: cannot find symbol
symbol : class Clock
location: package com.calender
add( new com.calender.Clock());
^
ClockFrame.java:17: cannot find symbol
symbol : class Clock
location: package com.calender
contentpane.add(new com.calender.Clock(),BorderLayout.CENTER);


I could understant its a classpath problem but i really stucked please help me to come out from this .
Thanks in advance

All search starts with beginner's luck and all search ends with victor's severly tested.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 40027
    
  28
Please consider which forum you should post in. Moving to "beginning Java" since this is not a GUI-related question.

Do you have a package name declared in either of your classes? In that case you need to have a directory ready to contain the .class files. If you search this forum for "compile package" you will find this problem comes up frequently. Afraid I haven't got the time for more details just now.
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14420
    
  23

It looks like your class Clock is not in the package com.calendar for some reason. Maybe you did not put "package com.calendar;" in your file Clock.java, you didn't put the source file in the right directory, or you didn't specify the classpath correctly. Note that the directory structure of your project must match the package structure.

For more information on how to create and use packages, see Creating and Using Packages in Sun's Java Tutorials.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
Nitish Bangera
Ranch Hand

Joined: Jul 15, 2009
Posts: 537

give javac the classpath where it can find clock.class

javac -classpath absolute/relative path Clockframe.java


[ SCJP 6.0 - 90% ] , JSP, Servlets and Learning EJB.
Try out the programs using a TextEditor. Textpad - Java 6 api
syruss kumar
Ranch Hand

Joined: Jul 23, 2009
Posts: 97
Thanks a lot .I have fixed this by using javac -d command
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 40027
    
  28
syruss kumar wrote:I have fixed this . . .
Well done, and thank you for telling us how you did it.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Cannot find symbol Error