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

Exception in thread "main"

Angela lewis
Ranch Hand

Joined: Mar 01, 2004
Posts: 100
i have created a folder com. In this folder i have created the following file


I compile it using
D:\>javac com\Hello.java

But i am unable to run it. i get the following error
Exception in thread "main" java.lang.NoClassDefFoundError: com\Hello

when i do D:\>java com\Hello
Please help
Vlado Zajac
Ranch Hand

Joined: Aug 03, 2004
Posts: 245
java parameter is fully qualified class name not file name so correct form is
d:\>java com.Hello

d:\>java com/Hello also works but not with \.
Angela lewis
Ranch Hand

Joined: Mar 01, 2004
Posts: 100
Still getting error

D:\>java com.Hello
Exception in thread "main" java.lang.NoClassDefFoundError: com/Hello
Elouise Kivineva
Ranch Hand

Joined: Feb 07, 2002
Posts: 154
If you want to comple the command is javac, not java.

What operating system are you using?

This link gives more info. about compiling under different operating systems and checking your java environment settings:
http://java.sun.com/docs/books/tutorial/rmi/compiling.html
Angela lewis
Ranch Hand

Joined: Mar 01, 2004
Posts: 100
Originally posted by Elouise Kivineva:
If you want to comple the command is javac, not java.

What operating system are you using?

This link gives more info. about compiling under different operating systems and checking your java environment settings:
http://java.sun.com/docs/books/tutorial/rmi/compiling.html


I am compiling it using

D:\>javac com\Hello.java

and it compiles fine.
i have a problem running it
I am doing
D:\>java com.Hello

and it gives the following error
Exception in thread "main" java.lang.NoClassDefFoundError: com/Hello

I am using windows 2000 pro
[ August 06, 2004: Message edited by: Angela lewis ]
Kalai Selvan
Ranch Hand

Joined: Jul 07, 2004
Posts: 79
Hi,
The problem may be with your classpath, check whether you have added
.(i.e current dir)in the classpath.

Kalai Selvan T.
Karthik shashikanth
Greenhorn

Joined: Feb 24, 2004
Posts: 1
FYI
Just try these steps

set classpath=%classpath%;.;
then run
java com.Hello

Hope this helps

cheers
Max Rahder
Ranch Hand

Joined: Nov 06, 2000
Posts: 177
You need to have your .class file in a directory hierarchy that matches its package. In your case, you could manually create a directory "com" and move Hello.class there, or you could compile using the -d directory. When you use -d, the compiler will place the .class file in the proper directory hierarchy at the specified location. For example,
>javac -d . Hello.java
will result in the Hello.class being created in a newly created folder "com" located in your working directory.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Exception in thread "main"