aspose file tools*
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
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: 24184
    
  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