The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.

Ambiguity and non-static variable reference error in java

I'm working on a program where i create an LED stopwatch but i honestly am completely stumped. The base code is done, but i haven't began to fill anything in. I took the code and put it all into one class, with subclasses strewn throughout. When i try to compile the code, i get this error:

Right now i'm just working on getting to program to compile and run, doing it each time i make any headway so that i can get errors before they pile up. Any suggestions on what to do about #2 specifically?

I'm new to this, this is my 1st year doing java, but i've done visual basic high school for 3 years so i understand it conceptually. I just don't know how to do it in java

Re: Can't decipher errors

I've uploaded the code.

To the above:

If you're using the dos prompt when you get the error, right click on the text and you should see an option called mark. Click that, then highlight the text and hit enter. It'll unhighlight and then you can paste it

Re: Can't decipher errors

Originally Posted by JavaPF

I've had a look myself and there seems to be all sorts of errors!! I cannot get this to compile.

Yer, I think that's why jenseits asked for help here.

The first & last error jenseits asked about are due to the way the imports are specified - to import every class in the packages. Since there is a Timer class in both java.util and javax.swing (which, for some reason has been imported twice), the compiler doesn't know which to use. The fix is to either specify the full qualified path to the Timer class when referring to it, or to import the classes individually for those packages so there's no confusion.

The other error is due to trying to use an instance variable from a static context. The fix is to either declare the variable static or to only reference it from a class instance.

jenseits has cross-posted this elsewhere, so further details are probably unnecessary.