• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

error while running the program

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I get the message "exception in thread "main" java.lang.NoClassDefFoundError :ar" (ar is the program name) while running the program.The program compiles without any problem.
This is the program :
class ar
{
public static void main(String args[])
{
int a[]=new int [5];
int t=0;
a[0]=4;a[1]=1;a[2]=3;a[3]=5;a[4]=2;
for(int i=0;i<=3;i++)
for(int j=i+1;j<=4;j++)
{
if(a[i]<a[j])>
{
t=i;
a[i]=j;
a[j]=t;
}
}
for(int k=1;k<=5;k++)
System.out.println(a[k]);
}
}
How can I solve the problem ?
 
Ranch Hand
Posts: 396
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
it seems that current directory is not in your classpath.
move to the directory u r having ur file in and try to run with following commandline
java -classpath %classpath%;. ar
this should work
do post ur response
deekasha
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hey if u still havae on siple thing is go to bin dir in JDK and pastethe class file
after that say java - <classfile>
this should work fine<in win98 it worked fine>even In NT it should work fine
 
zainab topiwala
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by deekasha gunwant:
hi,
it seems that current directory is not in your classpath.
move to the directory u r having ur file in and try to run with following commandline
[b] java -classpath %classpath%;. ar

this should work
do post ur response
deekasha
[/B]


thanks,your solution worked fine.
can you please tell me more about classpath.
thanks ,once again,
zainab
 
Did Steve tell you that? Fuh - Steve. Just look at this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic