The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
July 2000

Advertisement

Advertisement

This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

Changing name

Posted by Shanu on July 06, 2000 at 1:36 AM

Hi

I'm using JDK1.2.2. Initially, I thought about the Button name
as well, since there is already a Button class in java.awt.*.
Therefore I changed the name to ButtonAbc.java

However I still get these errors....

C:\JDK1.2.2\BIN\Button.java:4: Class ButtonAbc already defined in C:\jdk1.2.2\bin\ButtonAbc.java.
public class ButtonAbc extends Applet{
^
error: File C:\JDK1.2.2\BIN\Button.java does not contain type Button as expected. Please adjust the class path so that the file does not appear in the unnamed package.
C:\jdk1.2.2\bin\ButtonAbc.java:6: Class Button not found.
Button b1=new Button("Button 1");
^
C:\jdk1.2.2\bin\ButtonAbc.java:6: Class Button not found.
Button b1=new Button("Button 1");
^
C:\jdk1.2.2\bin\ButtonAbc.java:7: Class Button not found.
Button b2=new Button("Button 2");
^
C:\jdk1.2.2\bin\ButtonAbc.java:7: Class Button not found.
Button b2=new Button("Button 2");
^
C:\jdk1.2.2\bin\ButtonAbc.java:11: Class Button not found in void init().
add(b1);
^
C:\jdk1.2.2\bin\ButtonAbc.java:12: Class Button not found in void init().
add(b2);

After explicitly importing Button class ( import java.awt.Button; ),
everything in fine.

Shanu


> There is no problem initializing b1 and b2 in one declaration. The problem is the name of the applet. Change the name from Button to anything else like Button1 and your code will compile fine. It's because Button is a Java defined class.

> Thanx
> Kishori

> > import java.awt.*;
> > import java.applet.*;

> > public class Button extends Applet{
> > Button
> > b1=new Button("Button 1"),
> > b2=new Button("Button 2");
> > public void init(){
> > add(b1);
> > add(b2);
> > }
> > }

> > the above is a little program direct from the book Thinking in Java.But I can not interpret it.two error message prompt up saying" wrong number of arguments in constructor"
> > I also saw other books, this program is proved to be correct . But Why can't it be complied with JDK1.2.2?
> >





Replies:

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us