Another Problem with java.lang.NoClassDefFoundError
Hello. I'm working in NetBeans. When I run my project, I get the following error:
"Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: textfiles/ReadFile
at form_control_lession.FormObjects.menuItemOpenActio nPerformed(FormObjects.java: 295) - etc....
....
Caused by: java.lang.ClassNotFoundException: textfiles.ReadFile
at java.net.URLClassLoader$1.run(URLClassLoader.java: 366) etc....."
My program uses this class ReadFile in the textfiles package. The program includes this import statement:
Code:
package form_control_lession;
import java.io.IOException;
import javax.swing.filechooser.FileFilter;
import javax.swing.filechooser.FileNameExtensionFilter;
import textfiles.ReadFile;
public class FormObjects extends javax.swing.JFrame {
and further in the program, referencing the ReadFile class:
Code:
try { // displays a text file in the taOne text area.
ReadFile file_read = new ReadFile(file_name);
String[] aryLines = file_read.OpenFile();
String theText = ("");
int i;
for (i =0; i < aryLines.length; i++) {
theText = theText + aryLines[i] + '\n';
}
taOne.setText(theText);
}
If I understand the error messages correctly, java can't find this textfiles.ReadFile class. Can anyone help me fix this?
Thank you.
Re: Another Problem with java.lang.NoClassDefFoundError
Quote:
ClassNotFoundException: textfiles.ReadFile
Where is the definition for the class that is not found? Is the .class file in a folder on disk or in a jar file?
The definition must be available via the classpath so the JVM can find it.
Re: Another Problem with java.lang.NoClassDefFoundError
Hello. Thanks for your reply.
All files reside on my computer's C:/ drive - FormObjects (has main method), and ReadFiles (in the package textfiles). None of this are .JAR files. Package textfiles is a folder, and ReadFiles is a class file.
Perhaps I need to include the path to package textfiles in the import statement. I will try that and report back.
Thanks again.
Re: Another Problem with java.lang.NoClassDefFoundError
Update: I might have found my problem - which of course exists between my ears!!!
Because this is the second time I have written this program, I have two folders referencing this program. So I have confused which folder I am working in. I will correct this situation and if I am still having problems I will return to the forum with more questions.
Thanks.