![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Jan 2005
Posts: 29
Rep Power: 0
![]() |
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! |
|
|
|
|
|
#2 |
|
Hobbyist Programmer
|
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 |
|
|
|
|
|
#3 |
|
Newbie
Join Date: Jan 2005
Posts: 29
Rep Power: 0
![]() |
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 |
|
|
|
|
|
#4 |
|
Professional Programmer
|
You should run the program with :
java Example java Example.class
__________________
Don't take life too seriously, it's not permanent ! Last edited by xavier; Feb 20th, 2005 at 1:33 PM. |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|