Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Feb 20th, 2005, 12:42 PM   #1
n3o_X
Newbie
 
Join Date: Jan 2005
Posts: 29
Rep Power: 0 n3o_X is on a distinguished road
Errors when compiling simple program

I'm trying to program a small program:

class example {
public static void Main (String args[]){
System.out.println("java drives the web");
}
}

this file is Example.java.

I then compile the file: javac C:\java\Example.java

When i try running the file with: java C:\java\Example.class i get the error:

Exception in thread "main" java.lang.NoClassDefFoundError: C:\java\Example/class

Any way I can fix this?

Thanks for the help!
n3o_X is offline   Reply With Quote
Old Feb 20th, 2005, 1:15 PM   #2
ZenMasterJG
Hobbyist Programmer
 
ZenMasterJG's Avatar
 
Join Date: Nov 2004
Location: Boston, MA
Posts: 148
Rep Power: 4 ZenMasterJG is on a distinguished road
Send a message via AIM to ZenMasterJG
make sure the filename is the same as the class name (you said class example and javac Example.java)
Also, it should be:
public static void main(String[] args)
Good luck
ZenMasterJG is offline   Reply With Quote
Old Feb 20th, 2005, 1:23 PM   #3
n3o_X
Newbie
 
Join Date: Jan 2005
Posts: 29
Rep Power: 0 n3o_X is on a distinguished road
Hmm i tried what you said but still no luck. I am still getting the same error.

here is my program:
class Example {
public static void main(String[] args){
System.out.println("java drives the web");
}
}

x
n3o_X is offline   Reply With Quote
Old Feb 20th, 2005, 1:31 PM   #4
xavier
Professional Programmer
 
xavier's Avatar
 
Join Date: Oct 2004
Location: .ro
Posts: 383
Rep Power: 4 xavier is on a distinguished road
Send a message via Yahoo to xavier
You should run the program with :
java Example
not
 java Example.class
__________________
Don't take life too seriously, it's not permanent !

Last edited by xavier; Feb 20th, 2005 at 1:33 PM.
xavier is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 9:48 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC