Results 1 to 4 of 4
- 10-05-2012, 05:49 PM #1
Member
- Join Date
- Mar 2011
- Posts
- 88
- Rep Power
- 0
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:
and further in the program, referencing the ReadFile class:Java 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 {
If I understand the error messages correctly, java can't find this textfiles.ReadFile class. Can anyone help me fix this?Java 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); }
Thank you.
- 10-05-2012, 06:41 PM #2
Re: Another Problem with java.lang.NoClassDefFoundError
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?ClassNotFoundException: textfiles.ReadFile
The definition must be available via the classpath so the JVM can find it.If you don't understand my response, don't ignore it, ask a question.
- 10-05-2012, 07:08 PM #3
Member
- Join Date
- Mar 2011
- Posts
- 88
- Rep Power
- 0
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.
- 10-05-2012, 07:35 PM #4
Member
- Join Date
- Mar 2011
- Posts
- 88
- Rep Power
- 0
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.
Similar Threads
-
java.lang.NoClassDefFoundError:
By Gowramma in forum New To JavaReplies: 0Last Post: 05-02-2012, 08:57 PM -
Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/star/lang/XEventLi
By baktha.thalapathy in forum New To JavaReplies: 5Last Post: 06-02-2010, 01:05 PM -
Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/star/lang/XEventLi
By baktha.thalapathy in forum Advanced JavaReplies: 3Last Post: 06-01-2010, 03:01 PM -
java.lang.NoClassDefFoundError:
By jeepcreep11 in forum New To JavaReplies: 3Last Post: 03-13-2009, 11:58 AM -
java.lang.NoClassDefFoundError
By J_a_y in forum New To JavaReplies: 2Last Post: 08-07-2007, 11:51 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks