• Post Reply Bookmark Topic Watch Topic
  • New Topic

installation probs  RSS feed

 
robert stevens
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i installed jdk 1.6
everything is fine
i copy pasted the following code

public class HelloWorld
{
public static void main( String[] args )
{
System.out.println("hello world!");
}
}

i compiled
compilation went fine.
when i try to run it
it gives the following msg
"exception in thread "main" Java.lang.NoClassDefFoundError : HelloWorld

what is that supposed to mean???
 
Gavin Tranter
Ranch Hand
Posts: 333
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What command did you give Java to run.
I very much doubt that this is an installation problem, the error is basicly telling you that Java cant find the HelloWorld class (HelloWorld.class), you need the HellowWorld.class to be either on the classpath, or to be executing java from the directory where HelloWorld.class exists.

G
 
robert stevens
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
by the way i gave following the commands
javac HelloWorld.java (i was at the directory where i was saving my programs (not bin) )
//it the created a Helloworld.class file in that directory
java HelloWorld
//this gave me the error message
when i copied the HelloWorld.class file in the bin directory and typed the same command again it worked.

but if it compiles in that directory why does it not run in it???
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you entered the java command to run the program, were you still at the same directory (NOT the JDK bin directory)?

Are you following Sun's Hello World Tutorial for Windows?
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!