This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes NoClassDefFoundError Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "NoClassDefFoundError" Watch "NoClassDefFoundError" New topic
Author

NoClassDefFoundError

seetharaman jayaraman
Ranch Hand

Joined: Feb 18, 2008
Posts: 43
my class file "Hello.class" is inside the package "rmi".
"rmi" folder is in c:
I am getting NoClassDefFoundError while executing "Hello" from c:> or from c:\rmi>
I tried setting classpath as %classpath%;c:\; and %classpath%;c:\rmi\; etc
but i could not solve the problem
The code of Hello.java is as:
public class Hello
{
public static void main(String a[])
{
System.out.println("hei");
}
}

please help
all the best and advance thanks.

Added on 30.04.2008 only like java rmi.Hello works, it seems no way to use like java Hello
[ April 30, 2008: Message edited by: seetharaman jayaraman ]

Seetharaman Jayaraman
Only Change is Changeless
Amit Ghorpade
Bartender

Joined: Jun 06, 2007
Posts: 2716
    
    6

Hi,
I am getting NoClassDefFoundError while executing "Hello" from c:> or from c:\rmi>

I guess you have not compiled Hello.java, hence the error.
And to execute the program you need to say java Hello and not just "Hello"


Hope this helps


SCJP, SCWCD.
|Asking Good Questions|
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 37953
    
  22
. . . and have you got ;. or ;.; or .; anywhere in your classpath? On windows you ought to have at least one of those three (though it doesn't seem to do any harm to have all three!).
Charlie Newman
Greenhorn

Joined: Apr 22, 2008
Posts: 4
I have just started this game too. I've found that Windows XP does not like the "%" at all. Also, if you go and change your path, close your command promt. I hope this help some.
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

HI ram,

better you set classpath in your envoronment variable...give java class file folder path to the classpath..

thanks & regards,
seetharaman
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 37953
    
  22
Originally posted by seetharam venk:
HI ram,

better you set classpath in your envoronment variable...give java class file folder path to the classpath..

thanks & regards,
seetharaman
Disagree. You want the folder with java.exe (for Windows) to be in the PATH, and you want a . for current directory in your classpath. Any classpath setting can be left for more advanced programming, and you can do that from the command line or a manifest file in a .jar.
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Hi Campbell Ritchie,

well, to use javac,you need path variable right?..i was saying about to run a java file(i.e,to use java) you need classpath..

thanks & regards,
seetharaman
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 37953
    
  22
You usually only need to set the classpath if you have executable .class files in several folders. So, you don't usually need to set the classpath for executing simple Java applications.
You virtually always need the PATH set to get anything to execute.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: NoClassDefFoundError
 
Similar Threads
NoClassDefFoundError
NoClassDefFoundError
NoClassDefFoundError
NoClassDefFoundError
NoClassDefFoundError!?