This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes DBFileReader Noclassdeffounderror -Please help keep me sane! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "DBFileReader Noclassdeffounderror -Please help keep me sane!" Watch "DBFileReader Noclassdeffounderror -Please help keep me sane!" New topic
Author

DBFileReader Noclassdeffounderror -Please help keep me sane!

John Mhenry
Greenhorn

Joined: Mar 15, 2013
Posts: 9
I'm trying to use the 'DBFileReader' code from the SCJD FAQ.
It seems to work smoothly for everyone, except me.
Whenever I run it I get a 'noclassdeffounderror'.

The package in the file is 'suncertify.db'
I have the .class saved in classes projects\classes\suncertify\db\DBFileReader.class
I have my database saved in c:\, which is the location in the java.
I compile fine, however, I can run.

This is the command which is failing:
Project\Classes>java suncertify\db\DBFileReader

Output:
Exception in thread "main" java.lang.NoClassDefFoundError: suncertify\db\DBFileR
eader (wrong name: suncertify/db/DBFileReader)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:791)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:14
2)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:482)

I have tried this with a wide variety of -cp calls. Simply not working, can someone please advise?
John Mhenry
Greenhorn

Joined: Mar 15, 2013
Posts: 9
Just to give a bit more info on this.

I even tried removing the 'package suncertify.db;' line.

Transferring the db file and java code to c:\ and rerunning.

Still did not work.

Everything I try is getting the exact same error.
I can't move forward till I get this.

FYI, my assignment states:
4 byte numeric, magic cookie value. Identifies this as a data file
4 byte numeric, total overall length in bytes of each record
2 byte numeric, number of fields in each record
Schema description section.
Repeated for each field in a record:
2 byte numeric, length in bytes of field name
n bytes (defined by previous entry), field name
2 byte numeric, field length in bytes
end of repeating block

John Mhenry
Greenhorn

Joined: Mar 15, 2013
Posts: 9
This is going to sound weird.

I tried the code in Netbeans(yeah, I know, don't kill me).

It worked!

I think it has something to do with the 'readonly' permissions on my folders, which always reverts back to readonly regardless of my efforts to change it.
Roberto Perillo
Bartender

Joined: Dec 28, 2007
Posts: 2247

What happens when you try to execute java suncertify.db.DBFileReader instead of java suncertify\db\DBFileReader in the command line?


Cheers, Bob "John Lennon" Perillo
SCJP, SCWCD, SCJD, SCBCD - Daileon: A Tool for Enabling Domain Annotations
Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 4926
    
  10

When launching a java class you should use package notation (and not directory notation). So, try with java suncertify.db.DBFileReader and maybe you have to add -cp . to add the current directory to the classpath (if you execute from project/classes directory). That should make it work.

Hope it helps!
Kind regards,
Roel

[edit] Oh no! Roberto was a few minutes faster with his reply


SCJA, SCJP (1.4 | 5.0 | 6.0), SCJD
http://www.javaroe.be/
John Mhenry
Greenhorn

Joined: Mar 15, 2013
Posts: 9
Roel De Nijs wrote:When launching a java class you should use package notation (and not directory notation). So, try with java suncertify.db.DBFileReader and maybe you have to add -cp . to add the current directory to the classpath (if you execute from project/classes directory). That should make it work.

Hope it helps!
Kind regards,
Roel

[edit] Oh no! Roberto was a few minutes faster with his reply


It worked.
My gratitude gentlemen.
Thanks
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: DBFileReader Noclassdeffounderror -Please help keep me sane!
 
Similar Threads
NoClassDefFoundError
NoClassDefFoundError
NoClassDefFoundError
NoClassDefFoundError
NoClassDefFoundError