• 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

NoClassDefFoundError

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
I am a newbie on linux.
I wrote this test program to run on JDK I installed. It compiled fine but when I tried to run it walked out with
<error message>
Exception in thread "main" java.lang.NoClassDefFoundError: Test
</error message>
Now yes I did type "java Test" and I did set CLASSPATH and JAVA_HOME variables right.
I am running Redhat 9.0 .
JDK installed is 1.4
I not able to figure out where I went wrong
I am not attaching code snipet coz it isnt doing much simple Hello world types.
Thanks in advance
/abhishek
 
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Abhishek,
Seems like your classpath doesnt point to the current directory. There is no need to set the classpath as an environment variable, its discouraged.
To quickly check if this is the problem try the following:
prompt> java -classpath . Test
This is the preferred method of setting the classpath. Basically, if your classpath is set for example in .bash_profile, and it doesnt include the current directory '.', then the default classpath when running the 'java' command which is the current directory, is ignored, and your Test class is therefore not found.
Check this: http://faq.javaranch.com/view?HowToSetTheClasspath
for general classpath info.
Nart
 
Not so fast naughty spawn! I want you to know about
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic