Win a copy of React Cookbook: Recipes for Mastering the React Framework this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Rob Spoor
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Tim Holloway
  • Piet Souris
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Frits Walraven
  • Himai Minh

NoClassDefFoundError

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I had written a HelloWorld program HelloWorld.java
class HelloWorld{
public static void main (String a[]){
System.out.println("hello...")
}
}
The program will compile fine.
When i execute the program it is giving the runtime error java.lang.NoCalassDefFoundError
The work around for this is to set the CLASSPATH variable to . (dot)
But why do we need to explicitely tell the interpreter to look for the classes in the current folder.
According to java tutorial the java interpreter by default looks for the classes in the current directory.
This problem is not happening in other machine..
Why is this is happening .
Iam using jdk 1.3
 
Ranch Hand
Posts: 2545
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by ShivaK Thadakamadla:
This problem is not happening in other machine..



actually, i got same problem before. sometimes you have to add the current directory to the path. it is wired.
 
John Lee
Ranch Hand
Posts: 2545
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
take a look at Class java.lang.NoClassDefFoundError
 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Let me assume that you use WINNT machine.
Please verify whether the CLASSPATH variable is set in your Environment variable.
Since you have said that it works in other machine. I do think this could be the possibility.
Sorry if you dont use WINNT.
 
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Details on classpath are found at http://java.sun.com/j2se/1.3/docs/tooldocs/win32/classpath.html.

The default class path is the current directory. Setting the CLASSPATH variable or using the -classpath command-line option overrides that default, so if you want to include the current directory in the search path, you must include "." in the new settings.

 
John Lee
Ranch Hand
Posts: 2545
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
here are more links:
Setting the class path
Java Tip 105: Mastering the classpath with JWhich
Classpath Info Page
 
If a regular clown is funny, then a larger clown would be funnier. Math. Verified by this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic