• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

running HelloWorld

 
David Malott
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Having trouble running HelloWorld. I have my programs in a folder called "java" off the c: drive. When I type in "java java\HelloWorld" I get the error message "Exception in thread "main" java.lang.NoClassDefFoundError: HelloWorld". I was able to complile it.
 
Peter Gragert
Ranch Hand
Posts: 424
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You work as follows:
staying in directory "work" contaning directory java
thus you have: ..\work\java\HelloWorld.java
and HelloWorld.java containing: "package java;"
compile:
javac java\HelloWorld.java
run:
java java.HelloWorld
YOu see the point and not the backslash?
But this should be asked at the beginners thread not here?!
 
Pauline McNamara
Sheriff
Posts: 4012
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yup, moving it over there now...
 
Marilyn de Queiroz
Sheriff
Posts: 9064
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually, it's in the first lesson of the Cattle Drive. I would have left it open here.
 
Pauline McNamara
Sheriff
Posts: 4012
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oops! Opened it up again (no replies in the Java in General forum, where it will be deleted now).
 
Marilyn de Queiroz
Sheriff
Posts: 9064
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
David,
I wonder why you are typing "java java\HelloWorld". After you compile HelloWorld.java using javac HelloWorld.java, can you see HelloWorld.class in the C:\java subdirectory? Did you add C:\java to your classpath? If so, you should be able to type "java HelloWorld" and watch the program run.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic