This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
This may seem very basic to some of you. But since it is the first time I am new to Java I would like to know what could be done to fix my problem. I am writing code to create JTable and it compiles fine but when I run it this is the error message: Exception in thread "main" java.lang.NoClassDefFoundError:suncertify\db\FbnModel (wrong name suncertify/db/FbnModel) Here are some snippets public class FbnModel extends JFrame { ... public void FlyTableModel() throws IOException { ..... } class FlyTableModel extends AbstractTableModel { } public FbnModel() { FlyTableModel model = new FlyTableModel(); JTable table = new JTable(model); } public static void main(String[] args) { FbnModel frame = new FbnModel(); frame.pack(); frame. } } Any hints would be appreciated Krishnan
Gurpreet Aulakh
Greenhorn
Joined: Jan 07, 2001
Posts: 12
posted
0
Look VERY HARD at the following code snippet public FbnModel() { FlyTableModel model = new FlyTableModel(); JTable table = new JTable(model); } Do a step by step analysis on what is happening. Hint, what happens at the end of the function? [This message has been edited by Gurpreet Aulakh (edited March 06, 2001).]
Karthik Guru
Ranch Hand
Joined: Mar 06, 2001
Posts: 1209
posted
0
May be i'm wrong. Have u packaged this java file under suncertify.db? if yes then try running by typing the following on the command prompt. java suncertify.db.FBNModel If NO then java FBNModel s'd work from the directory where u compiled the FBNModel file. regards karthik.
Originally posted by Swati krishnan: This may seem very basic to some of you. But since it is the first time I am new to Java I would like to know what could be done to fix my problem. I am writing code to create JTable and it compiles fine but when I run it this is the error message: Exception in thread "main" java.lang.NoClassDefFoundError:suncertify\db\FbnModel (wrong name suncertify/db/FbnModel) Here are some snippets public class FbnModel extends JFrame { ... public void FlyTableModel() throws IOException { ..... } class FlyTableModel extends AbstractTableModel { } public FbnModel() { FlyTableModel model = new FlyTableModel(); JTable table = new JTable(model); } public static void main(String[] args) { FbnModel frame = new FbnModel(); frame.pack(); frame. } } Any hints would be appreciated Krishnan
Swati krishnan
Greenhorn
Joined: Feb 09, 2001
Posts: 11
posted
0
I packaged it under suncertify.db and have all the classpaths and directories set up as required to the best of my knowledge. But still I am getting the same error. Also I am unable to find any error in the public FbnModel() code. How can I get this code to run. Thanks in advance Krishnan
Gurpreet Aulakh
Greenhorn
Joined: Jan 07, 2001
Posts: 12
posted
0
"Also I am unable to find any error in the public FbnModel() code." If the contructor is exactly as you have written it then YES THERE IS A PROBLEM !!! I am not going to tell you the answer you will have to figure it out on your own. I will tell you that what you think the contructor is doing and what it actually is doing are two separate things. What you should do is step through the code with a debugger and check each value. You will quickly see what is happening. Read the previous hint that I gave you! WHAT HAPPENS AT THE END OF THE FUNCTION CALL!!
Swati krishnan
Greenhorn
Joined: Feb 09, 2001
Posts: 11
posted
0
I tried fixing it by the following super("FbnModel"); and then made model and table global but still get the same error. Its phasing me out Krishnan public FbnModel() { super("FbnModel"); model = new FlyTableModel(); table = new JTable(model); }
davidlong
Greenhorn
Joined: Jan 28, 2001
Posts: 21
posted
0
Hi Swati: I hardly to find the problems with the code you gave. Is it possible the problem related with the runing command when you start Java VM. Did you start the executing your coding like this: java suncertify.db.FbnModel It should start the class with it's package name, not the directory structure name like: java suncertify/db/FbnModel, which definitely gave your ClassNotFoundExceptions in you case David
Swati krishnan
Greenhorn
Joined: Feb 09, 2001
Posts: 11
posted
0
Thanks david, seems like that was it java suncertify.db.FbnModel Thanks for bringing it to my attention Krishnan
Sam Wong
Ranch Hand
Joined: Dec 07, 2000
Posts: 133
posted
0
davidlong, Please read the JavaRanch Naming Policy and register using a name that complies with the rules. Thank you, Sam Wong
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.