aspose file tools*
The moose likes Beginning Java and the fly likes Execution problems Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Execution problems" Watch "Execution problems" New topic
Author

Execution problems

Roberto Diaz
Ranch Hand

Joined: Mar 08, 2002
Posts: 40
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

Joined: May 05, 2000
Posts: 13974
Do you have a main method and is it properly formatted? Show some code so we can take a look.


Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
Roberto Diaz
Ranch Hand

Joined: Mar 08, 2002
Posts: 40
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

Joined: May 05, 2000
Posts: 13974
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

Joined: Dec 10, 2001
Posts: 7023
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?


[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
Roberto Diaz
Ranch Hand

Joined: Mar 08, 2002
Posts: 40
I am using 1.4
Thanks for all the replies.
I had installed XML Spy and suspect that
messed up the CLASSPATH variable.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Execution problems