Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Tim Holloway
  • Carey Brown
  • salvin francis

Problem with my Java

 
Ranch Hand
Posts: 384
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey everyone,

I asked a question a couple of days ago about the BeatBox program from the Head First Java 2nd Ed book.

my program was fine, but it would not compile.

I emailed Bert bates, as he has helped me in the past, I got a reply.

He said that I should ask here if someone knows any tricks to get this fixed, other than a complete re-install of my java.

he gave me a program to test, this is the code:

expected output:


here is my compiler error:

StaticTest java:7: cannot find symbol
Symbol: constructor Box(int)
Location: class Box
Box b = new Box(BoxLayout.Y_AXIS);
1 error

is there a fix, or would I have to re-install java?

Davy
[ November 26, 2006: Message edited by: Davy Kelly ]
 
author
Posts: 23840
141
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Compiles and run fine here...

BTW, what version of Java are you using? What is the output when you run "java -version"?

Henry
 
Davy Kelly
Ranch Hand
Posts: 384
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hey,

version is:
java version "1.5.0_06"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05)
Java HotSpot(TM)Client VM (build 1.5.0_06-b05, mixed node, sharing)

that is what it says from my command prompt.

I have in my Java Folder 4 folders:
JDK 1.5.0_03
JRE 1.5.0_03
JRE 1.5.0_04
JRE 1.5.0_06

My java programs get stored in JDK 1.5.0_03 and when compiling I have the command line set at:
C:\program files\Java\jdk1.5.0_03>

davy
 
author and iconoclast
Posts: 24203
43
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You've created, someplace, your own class named "Box", and there's either a "Box.class" or "Box.java" (or both) laying about. The Java compiler thinks you're referring to your own "Box" class, when in fact you're intending to refer to the Box Swing component here. Carefully delete any copies of Box.java and/or Box.class -- unless they're essential to your project, in which case you'll need to change the example program a little.
 
Davy Kelly
Ranch Hand
Posts: 384
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ernest you are the man,

thank you, I got rid of the class Box yesterday but I never got ris of the Box.java file. thanks you, that has helped me.

I wish there was reputation points here, you would get a bundle.

davy
 
Ernest Friedman-Hill
author and iconoclast
Posts: 24203
43
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Davy Kelly:

I wish there was reputation points here, you would get a bundle.



Kind thank-yous are the best reward!
 
Let's get him boys! We'll make him read this tiny ad!
professionally read, modify and write PDF files from Java
https://products.aspose.com/pdf/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!