• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

cannot execute java command from command prompt

 
sarim raza
Ranch Hand
Posts: 232
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

the directory is right, thats where my .java file is
the javac command executes fine and creates the .class file
but when i give the java command to interpret the file i get the following error
Exception in thread main: java.lang.NoClassDefFoundError : HelloWorld
i have given whatever classpath i needed to give, note though that when i installed jdk1.3, i had a src.jar file which i think is the file where the path should point to, this was initially not located in the lib folder
 
Bosun Bello
Ranch Hand
Posts: 1510
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If your class is in a package, make sure you also include tha package name when trying to interpret. You can do a fimd for the class file created, then navigate to that directory and issue the command from there.

Bosun
 
Lucas Richardson
Ranch Hand
Posts: 32
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The problem isn't with java.exe not running. If it couldn't find the file, it would say "Bad Command or file name" (win 9x).
Post your source code. That error indicates that it's having a problem with your main method (like maybe it isn't there?)
 
Laojar Chuger
Ranch Hand
Posts: 111
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Most likely it was an error of wrong class path. Just type set classpath=.; and see what happens.
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
src.jar has NOTHING to do with anything. That is just included with the stuff so that you can read the Sun code if you want.
The CLASSPATH should include the \bin where the Sun files are, the "." current directory (probably) for convenience, and the directory where YOUR class file reside.
 
Ashish Hareet
Ranch Hand
Posts: 375
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try this -- at the command prompt give
java classname
where classname is the name of the class as you specified in your code keeping in mind that Java is case sensitive . If this makes your code work then what u need to do is save the file as "HelloWorld.java" & make sure that the class name in your code is "Helloworld" .
And if it is not this simple excuse my ignorance .
[This message has been edited by Ashish Hareet (edited July 14, 2001).]
[This message has been edited by Ashish Hareet (edited July 14, 2001).]
 
Marcos Maia
Ranch Hand
Posts: 977
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you have to set your classpath for the current directory where your java file is at.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic