Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Cannot find symbol Error

 
syruss kumar
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Campbell Ritchie
Sheriff
Posts: 48649
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15214
36
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

 
Nitish Bangera
Ranch Hand
Posts: 537
Eclipse IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
give javac the classpath where it can find clock.class

javac -classpath absolute/relative path Clockframe.java
 
syruss kumar
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot .I have fixed this by using javac -d command
 
Campbell Ritchie
Sheriff
Posts: 48649
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
syruss kumar wrote:I have fixed this . . .
Well done, and thank you for telling us how you did it.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic