• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Execution problems

 
Roberto Diaz
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to execute a simpe java progam.
It compiles without nay problems.
But on execution i get following error:
Exception in thread "main" java.lang.NoClassDefFoundError.
I can see the .class file.
 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you have a main method and is it properly formatted? Show some code so we can take a look.
 
Roberto Diaz
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I typed the following command at the prompt
set CLASSPATH=
and it worked. Any ideas ??
In which directory are the base JAVA classes
present, when we download JDK and how do we view
them (their source)??
BTW here is the code, very simple program
******************************
public class test
{
public static void main(String[] args)
{
int count = 0, sum = 0;
do
{
System.out.println("Count 1 " + count);
if(count % 3 == 0)
{
System.out.println(count%3);
continue;
}
System.out.println("Count 2 " + count);
System.out.println("Sum 1 " + sum);
sum+=count;
System.out.println("Sum 2 " + sum);
}
while(count++ < 11);
System.out.println("Final Sum " + sum);
}
}
***********************
TIA
 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The base java runtime jar files are in this directory (or something similar depending on which version of java you have installed):
C:\j2sdk1.4.1_01\jre\lib
What was in your classpath before you did the set command?
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
NoClassDefFoundError occurs when a class cannot be found at runtime. I would suspect that your previous CLASSPATH setting somehow did not include the location of the class you were trying to run as a program.
With recent versions of Java, the J2SE classes are hopefully found without their location being specified in the classpath.
Out of curiosity, what version of Java are you running?
 
Roberto Diaz
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using 1.4
Thanks for all the replies.
I had installed XML Spy and suspect that
messed up the CLASSPATH variable.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic