Hi,

I have a program that has a package that is imported in a class called Control.All the files are compiling correctly apart from when I try to import a package.

I am importing the package by

package carpkg;

and in my main there is

GUI gui = new GUI

but when I try to compile i get the error:

Bad class file: .\carpkg\GUI.class
class file contains wrong class: GUI

Does anyone have any idea how I might fix this?

Recommended Answers

All 4 Replies

package carpkg; declares a package, perhaps you want import packageName ?

Well what is the definition of GUI.class? The problem is probably that GUI.class isn't defining package carpkg; at the top of the file. or it could be that

GUI gui = new GUI

is missing it's ();

the GUI() was a typo I made while posting here.What do you mean by the definition of the GUI class?If you are asking what it does it is an interface.

i have also tryed importing pakage and this too does not work.

you cannot create an object from an interface.

public interface GUI{
public void showGUI();
}
public class blueGUI implements GUI {
public void showGUI(){
//somehow show gui in blue
}
}
GUI gui = new GUI();//WILL NOT WORK. cannot instantiate interface
blueGUI gui = new blueGUI();//WILL WORK
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.