f



getting error: java.lang.NoClassDefFoundError

Hi Guys,

im starting out in java and i'm getting the error: Exception in thread
"main" java.lang.NoClassDefFoundError: blurf

if i run "javac blurf.java", it compiles fine and without any troubles.

when i try to run it (its a simple hello world program) i get the above
error.

i need some help :)

-nat
0
me7582 (401)
3/2/2004 8:44:56 PM
comp.lang.java.programmer 52714 articles. 1 followers. Post Follow

4 Replies
758 Views

Similar Articles

[PageSpeed] 5

* NathanK <me@me.com> wrote:

> Hi Guys,
>
> im starting out in java and i'm getting the error: Exception in thread
> "main" java.lang.NoClassDefFoundError: blurf
>
> if i run "javac blurf.java", it compiles fine and without any troubles.
>
> when i try to run it (its a simple hello world program) i get the above
> error.

Wow to you run the programm?
Do you have a main() function?
May be a package-fault?


mabu

-- 
Are you Anonymous? Where? ... I don't think so ...

[ devnull{at}chaosfactory{dot}org | http://www.chaosfactory.org/ ]
0
3/2/2004 9:05:06 PM
On Wed, 03 Mar 2004 07:44:56 +1100, NathanK wrote:

> im starting out in java and 

<http://groups.google.com.au/groups?group=comp.lang.java.help>

> i'm getting the error: Exception in thread
> "main" java.lang.NoClassDefFoundError: blurf

And what input is causing that output?
Where is the class, where are you calling
the class from?

With the amount of information you fail
to supply, I don't think I could find the
Class on your system either.

-- 
Andrew Thompson
* http://www.PhySci.org/ Open-source software suite
* http://www.PhySci.org/codes/ Web & IT Help
* http://www.1point1C.org/ Science & Technology
0
SeeMySites (5478)
3/2/2004 10:26:24 PM
"NathanK" <me@me.com> wrote in message
news:4044f249@duster.adelaide.on.net...
> Hi Guys,
>
> im starting out in java and i'm getting the error: Exception in thread
> "main" java.lang.NoClassDefFoundError: blurf
>
> if i run "javac blurf.java", it compiles fine and without any troubles.
>
> when i try to run it (its a simple hello world program) i get the above
> error.
>
> i need some help :)
>
> -nat

Read Question 5 and 8.

http://www.xdweb.net/~dibblego/java/faq/answers.html#q5

Question 5.
How do I set the CLASSPATH variable for the Java Development Kit ?

Answer.
Generally, you do not set the CLASSPATH environment variable for a standard
SDK or JRE installation. The CLASSPATH environment variable is set for other
reasons, usually the installation of third-party libraries. Some people
(including myself) argue that setting the CLASSPATH environment variable at
all is bad practice; it should be set dynamically at each build. This keeps
the build machine clean from potential "contamination" from libraries in the
CLASSPATH. Setting the CLASSPATH environment variable was required for
installation of the SDK in versions prior to 1.2. This "myth" has
unfortunately carried over to later versions of Java and confusion has
resulted. A good rule of thumb is, "If you don't know how to set the
CLASSPATH (since you are relatively new to Java), don't set the CLASSPATH at
all". More information on the CLASSPATH environment variable can be found at
http://java.sun.com/j2se/1.4.2/docs/tooldocs/tools.html

http://www.xdweb.net/~dibblego/java/faq/answers.html#q8

Question 8.
What does this mean "Exception in Thread "main"
java.lang.NoClassDefFoundError <something> " ?

Answer.
This means that the Java Virtual Machine (JVM) cannot find the class that
you are referring to. The error is followed by the class name that the JVM
was asked to load. The directory that contains this class must be in your
CLASSPATH environment variable. If your CLASSPATH is not set to anything,
then the class must be located in the same directory from which the JVM is
invoked (package relative). The JVM is generally (but not always) invoked by
executing the java executable followed by the class name at a command line.

One common problem arises when executing a jar file (using the -jar switch),
which ignores all CLASSPATH settings, except for that specified in the Java
ARchive manifest file. This may be contrary to general intuition, but it
makes perfect sense when you think about it. This is outlined in The JAR
File Specification.

A common error is to append the .class file extension to the class name when
invoking the JVM; this will result in an error similar to the following:
Exception in thread "main" java.lang.NoClassDefFoundError: MyClass/class
Fix this problem by removing the .class file extension from your command.

Wrong
> java MyClass.class

Right
> java MyClass


-- 
Tony Morris
(BInfTech, Cert 3 I.T.)
Software Engineer
(2003 VTR1000F)
Sun Certified Programmer for the Java 2 Platform (1.4)
Sun Certified Developer for the Java 2 Platform


0
dibblego (448)
3/2/2004 10:51:27 PM
On Wed, 3 Mar 2004 08:51:27 +1000, Tony Morris wrote:

> "NathanK" <me@me.com> wrote in message
> news:4044f249@duster.adelaide.on.net...
>> Hi Guys,
>>
>> im starting out in java and i'm getting the error: Exception in thread
>> "main" java.lang.NoClassDefFoundError: blurf
....
> Question 5.
> How do I set the CLASSPATH variable for the Java Development Kit ?
> 
> Answer.
> Generally, you do not set the CLASSPATH environment variable for a standard
> SDK or JRE installation. The CLASSPATH environment variable is set for other
> reasons, usually the installation of third-party libraries. Some people
> (including myself) argue that setting the CLASSPATH environment variable at
> all is bad practice; it should be set dynamically at each build. 

That is what Sun says as well, trouble is,
they keep moving the documents that *say*
that.  It is most exasperating.

-- 
Andrew Thompson
* http://www.PhySci.org/ Open-source software suite
* http://www.PhySci.org/codes/ Web & IT Help
* http://www.1point1C.org/ Science & Technology
0
SeeMySites (5478)
3/2/2004 11:49:40 PM
Reply: