• Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem with my Java  RSS feed

 
Davy Kelly
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 ]
 
Henry Wong
author
Sheriff
Posts: 23283
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor 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
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • 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
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • 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!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!