This week's book giveaways are in the iOS and Features new in Java 8 forums.
We're giving away four copies each of Barcodes with iOS: Bringing together the digital and physical worlds and Core Java for the Impatient and have the authors on-line!
See this thread and this one for details.
The moose likes Beginning Java and the fly likes basic questin Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Barcodes with iOS this week in the iOS forum
or Core Java for the Impatient in the Java 8 forum!

JavaRanch » Java Forums » Java » Beginning Java
Bookmark "basic questin" Watch "basic questin" New topic
Author

basic questin

Andrei Pop
Ranch Hand

Joined: Oct 08, 2004
Posts: 43
Hi,

I'm trying to run a simple program:

class Hello
{
public static void main(String[] args)
{
System.out.println("Hello World!");
}
}

It compiles fine. When I run it I got this:

E:\work\java>java Hello
Exception in thread "main" java.lang.NoClassDefFoundError: Hello

I don't know what could be.
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24189
    
  34

Hi Andrei,

Welcome to JavaRanch!

The problem is that, knowingly or unknowingly, you've set your CLASSPATH environment variable (which Java uses to find .class files), and the value you've set it to does not include "." (dot, meaning the current directory). The best thing to do is to not have CLASSPATH set at all, but if you must set it, then include "." as an entry.

See the CLASSPATH page in the JavaRanch FAQ for more information.


[Jess in Action][AskingGoodQuestions]
Andrei Pop
Ranch Hand

Joined: Oct 08, 2004
Posts: 43
Thank you!

I read Sun's tutorial on running the first cup of Java and they didn't say anything about setting a CLASSPATH. But, I have a CLASSPATH variable already set by another application. Therefore, I added the . (dot) and everything works fine.

Thanks again!

And I can't notice how quick the answers are on Javaranch.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: basic questin