• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

cannot execute java command from command prompt

 
Ranch Hand
Posts: 232
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 1514
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?)
 
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Most likely it was an error of wrong class path. Just type set classpath=.; and see what happens.
 
"The Hood"
Posts: 8521
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 375
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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).]
 
Ranch Hand
Posts: 977
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you have to set your classpath for the current directory where your java file is at.
 
reply
    Bookmark Topic Watch Topic
  • New Topic