NoClassDefFoundError error

M

M K

I have created 2 forms and they are in the same
folder(c:\xxx\xxx\ListSaver2). I put

package ListSaver2;

at the top of each .java file

When I compile the application I get this..

java.lang.NoClassDefFoundError: DataStorageFacility (wrong name:
ListSaver2/DataStorageFacility)
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java :539)
at java.security.SecureClassLoader.defineClass(Secure ClassLoader.java:123)
at java.net.URLClassLoader.defineClass(URLClassLoader .java:251)
at java.net.URLClassLoader.access$100(URLClassLoader. java:55)
at java.net.URLClassLoader$1.run(URLClassLoader.java: 194)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.j ava:187)
at java.lang.ClassLoader.loadClass(ClassLoader.java:2 89)
at sun.misc.Launcher$AppClassLoader.loadClass(Launche r.java:274)
at java.lang.ClassLoader.loadClass(ClassLoader.java:2 35)
at java.lang.ClassLoader.loadClassInternal(ClassLoade r.java:302)
Exception in thread "main"


Here is main:
public static void main(String args[]) {
new DataStorageFacility().show(); //trying to show itself
}

I am able to build and complie each one w/o any errors but when I try to run
the app
I get the errors.

I can send more code if needed but it is a lot so I try to submit just what
is needed (which may or may not be enough). I was hoping that someone could
point me where in my code the problem could be.

Thanks for any help in advance.
Mark
 
K

klynn47

The problem isn't with the code other than possibly the package
statement. It mainly seems to be a problem with your CLASSPATH, and the
package statement. What is your CLASSPATH?
 
M

M K

I am not sure how to find that in NetBeans but all the .java files are
listed in:

C:\MyDocs\My Java\MyProjects\ListSaver2

all .java files have

package ListSaver2;

I have unmounted and remounted that path many times
 
R

Roland

I have created 2 forms and they are in the same
folder(c:\xxx\xxx\ListSaver2). I put

package ListSaver2;

at the top of each .java file

When I compile the application I get this..

java.lang.NoClassDefFoundError: DataStorageFacility (wrong name:
ListSaver2/DataStorageFacility) [...]
Here is main:
public static void main(String args[]) {
new DataStorageFacility().show(); //trying to show itself
}

I am able to build and complie each one w/o any errors but when I try to run
the app
I get the errors.

I can send more code if needed but it is a lot so I try to submit just what
is needed (which may or may not be enough). I was hoping that someone could
point me where in my code the problem could be.

Thanks for any help in advance.
Mark

Your classpath and/or the name used to launch your program is incorrect.

Probably you are using a commandline like
java -classpath "c:\xxx\xxx\ListSaver2" DataStorageFacility

The classpath should point to the package root directory (c:\xxx\xxx\)
and youy should use the fully qualified classname, i.e.
ListSaver2.DataStorageFacility

Try the following command to launch you program
java -classpath "c:\xxx\xxx\" ListSaver2.DataStorageFacility

Or, if "c:\xxx\xxx\" is your current directory:
java -classpath . ListSaver2.DataStorageFacility

--
Regards,

Roland de Ruiter
` ___ ___
`/__/ w_/ /__/
/ \ /_/ / \
 
M

M K

Here is my classpath

..;c:\j2sdk1.4.2_05\bin;c:\j2sdk1.4.2_05

Is there anyway to add C:\MyDocs\My Java\* (all folders within My Java and
its subfolders)

Roland said:
I have created 2 forms and they are in the same
folder(c:\xxx\xxx\ListSaver2). I put

package ListSaver2;

at the top of each .java file

When I compile the application I get this..

java.lang.NoClassDefFoundError: DataStorageFacility (wrong name:
ListSaver2/DataStorageFacility) [...]
Here is main:
public static void main(String args[]) {
new DataStorageFacility().show(); //trying to show itself
}

I am able to build and complie each one w/o any errors but when I try to run
the app
I get the errors.

I can send more code if needed but it is a lot so I try to submit just what
is needed (which may or may not be enough). I was hoping that someone could
point me where in my code the problem could be.

Thanks for any help in advance.
Mark

Your classpath and/or the name used to launch your program is incorrect.

Probably you are using a commandline like
java -classpath "c:\xxx\xxx\ListSaver2" DataStorageFacility

The classpath should point to the package root directory (c:\xxx\xxx\)
and youy should use the fully qualified classname, i.e.
ListSaver2.DataStorageFacility

Try the following command to launch you program
java -classpath "c:\xxx\xxx\" ListSaver2.DataStorageFacility

Or, if "c:\xxx\xxx\" is your current directory:
java -classpath . ListSaver2.DataStorageFacility

--
Regards,

Roland de Ruiter
` ___ ___
`/__/ w_/ /__/
/ \ /_/ / \
 
M

M K

Still the same error when I put in the full path (I unmounted and remounted
as well) I am using NetBeans 3.6

..;c:\j2sdk1.4.2_05\bin;c:\j2sdk1.4.2_05;C:\MyDocs\My
Java\MyProjects\ListSaver2

Roland said:
I have created 2 forms and they are in the same
folder(c:\xxx\xxx\ListSaver2). I put

package ListSaver2;

at the top of each .java file

When I compile the application I get this..

java.lang.NoClassDefFoundError: DataStorageFacility (wrong name:
ListSaver2/DataStorageFacility) [...]
Here is main:
public static void main(String args[]) {
new DataStorageFacility().show(); //trying to show itself
}

I am able to build and complie each one w/o any errors but when I try to run
the app
I get the errors.

I can send more code if needed but it is a lot so I try to submit just what
is needed (which may or may not be enough). I was hoping that someone could
point me where in my code the problem could be.

Thanks for any help in advance.
Mark

Your classpath and/or the name used to launch your program is incorrect.

Probably you are using a commandline like
java -classpath "c:\xxx\xxx\ListSaver2" DataStorageFacility

The classpath should point to the package root directory (c:\xxx\xxx\)
and youy should use the fully qualified classname, i.e.
ListSaver2.DataStorageFacility

Try the following command to launch you program
java -classpath "c:\xxx\xxx\" ListSaver2.DataStorageFacility

Or, if "c:\xxx\xxx\" is your current directory:
java -classpath . ListSaver2.DataStorageFacility

--
Regards,

Roland de Ruiter
` ___ ___
`/__/ w_/ /__/
/ \ /_/ / \
 
R

Roland

Still the same error when I put in the full path (I unmounted and remounted
as well) I am using NetBeans 3.6

..;c:\j2sdk1.4.2_05\bin;c:\j2sdk1.4.2_05;C:\MyDocs\My
Java\MyProjects\ListSaver2

Have you tried running it from the commandline. It may give some insight
in how Java packages and the Classpath relate.

If you want to use Netbeans, mount the parent directory
C:\MyDocs\My Java\MyProjects\
rather than the directory of package 'ListSaver2'
C:\MyDocs\My Java\MyProjects\ListSaver2
--
Regards,

Roland de Ruiter
` ___ ___
`/__/ w_/ /__/
/ \ /_/ / \
 
A

Andrew Thompson

I am using NetBeans 3.6 ...

That is irrelevant. The problem is that you do not understand
what you are doing. Figure out how it works on the command line
and NetBeans (Eclipse, JBuilder, Vi, Emacs, TextPad..) will be
easier to configure to your requirements.

I also suggest you stop adding things to the classpath,
that will not solve the problem.

For help on packages, start here..
<http://java.sun.com/docs/books/tutorial/java/interpack/packages.html>

For Sun's take on adding everything to the class path, check here..
<http://java.sun.com/j2se/1.5.0/docs/tooldocs/windows/classpath.html>
(setting the classpath environment variable is mentioned in the
first paragraph)

For a better group for beginners
<http://www.physci.org/codes/javafaq.jsp#cljh>

On IDE's for people learning Java
<http://qa.jtiger.org/GetQAndA.actio...neNumbers=true&showCodeBorder=true&codeStyle=>

HTH
 
M

Mr Moiz Rassiwala

i suggest u to get rid of netbeans and work in eclipse. it is an excellent IDE.
you wont have to worry about classpaths then. take a look.
Still the same error when I put in the full path (I unmounted and remounted
as well) I am using NetBeans 3.6

.;c:\j2sdk1.4.2_05\bin;c:\j2sdk1.4.2_05;C:\MyDocs\My
Java\MyProjects\ListSaver2

Roland said:
I have created 2 forms and they are in the same
folder(c:\xxx\xxx\ListSaver2). I put

package ListSaver2;

at the top of each .java file

When I compile the application I get this..

java.lang.NoClassDefFoundError: DataStorageFacility (wrong name:
ListSaver2/DataStorageFacility) [...]
Here is main:
public static void main(String args[]) {
new DataStorageFacility().show(); //trying to show itself
}

I am able to build and complie each one w/o any errors but when I try to run
the app
I get the errors.

I can send more code if needed but it is a lot so I try to submit just what
is needed (which may or may not be enough). I was hoping that someone could
point me where in my code the problem could be.

Thanks for any help in advance.
Mark

Your classpath and/or the name used to launch your program is incorrect.

Probably you are using a commandline like
java -classpath "c:\xxx\xxx\ListSaver2" DataStorageFacility

The classpath should point to the package root directory (c:\xxx\xxx\)
and youy should use the fully qualified classname, i.e.
ListSaver2.DataStorageFacility

Try the following command to launch you program
java -classpath "c:\xxx\xxx\" ListSaver2.DataStorageFacility

Or, if "c:\xxx\xxx\" is your current directory:
java -classpath . ListSaver2.DataStorageFacility

--
Regards,

Roland de Ruiter
` ___ ___
`/__/ w_/ /__/
/ \ /_/ / \
 
M

M K

Have you tried NetBeans? I have tried Eclipse, JCreator and WSAD and to me
NetBeans is the best. It has a few issues but for the most part it has what
I want and its just a matter of learning its features. It is very similar
to Eclipse except its namings are more like WSAD/Rational. I personally
don't care for any IBM or ex IBM products.

Mr Moiz Rassiwala said:
i suggest u to get rid of netbeans and work in eclipse. it is an excellent IDE.
you wont have to worry about classpaths then. take a look.
Still the same error when I put in the full path (I unmounted and remounted
as well) I am using NetBeans 3.6

.;c:\j2sdk1.4.2_05\bin;c:\j2sdk1.4.2_05;C:\MyDocs\My
Java\MyProjects\ListSaver2

Roland said:
On 16-6-2005 17:43, M K wrote:
I have created 2 forms and they are in the same
folder(c:\xxx\xxx\ListSaver2). I put

package ListSaver2;

at the top of each .java file

When I compile the application I get this..

java.lang.NoClassDefFoundError: DataStorageFacility (wrong name:
ListSaver2/DataStorageFacility)
[...]
Here is main:
public static void main(String args[]) {
new DataStorageFacility().show(); //trying to show itself
}

I am able to build and complie each one w/o any errors but when I try
to
run
the app
I get the errors.

I can send more code if needed but it is a lot so I try to submit
just
what
is needed (which may or may not be enough). I was hoping that
someone
could
point me where in my code the problem could be.

Thanks for any help in advance.
Mark

Your classpath and/or the name used to launch your program is incorrect.

Probably you are using a commandline like
java -classpath "c:\xxx\xxx\ListSaver2" DataStorageFacility

The classpath should point to the package root directory (c:\xxx\xxx\)
and youy should use the fully qualified classname, i.e.
ListSaver2.DataStorageFacility

Try the following command to launch you program
java -classpath "c:\xxx\xxx\" ListSaver2.DataStorageFacility

Or, if "c:\xxx\xxx\" is your current directory:
java -classpath . ListSaver2.DataStorageFacility

--
Regards,

Roland de Ruiter
` ___ ___
`/__/ w_/ /__/
/ \ /_/ / \
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,071
Latest member
MetabolicSolutionsKeto

Latest Threads

Top