Help coderanch get a
new server
by contributing to the fundraiser
  • 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
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

java unable to recognize class where my IDE does

 
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
in a strange manner the JVM is unable to recognize a class file when is give
java ClassName
but before you can ask me to check whether the source code and class name matches ofcourse it does and more over i am able to run the file using an IDE.

But when i use command prompt to compile and run i am able to compile but i am unable to run the class file and the error i am receiving is as if there is no such class.

i even tried checking the bin directory what my IDE gentrates for the src(source) directory which is working properly in the IDE is unable to run with command prompt.

the machine i am using is running windows vista.
 
author
Posts: 23956
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

It would help if you told us the exact error (the printout when you ran it).

If I had to guess the error (with no info), I would say its the class path -- as that is one of those things that the IDE takes care of, and most beginners mess up.

Henry
 
saipraneeth nallapareddy
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Seek.java contains Seek class
and when i run it gives me this error.
 
Sheriff
Posts: 22796
131
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is class Seek perhaps member of a package?
 
saipraneeth nallapareddy
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
no packages are used
 
Henry Wong
author
Posts: 23956
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

You need to add the current directory, ".", to the class path.

Henry
 
saipraneeth nallapareddy
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you mean to say
java -d . Seek
 
Henry Wong
author
Posts: 23956
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

saipraneeth nallapareddy wrote:you mean to say
java -d . Seek



java -cp %JMF_HOME%\lib\jmf.jar;. Seek
 
saipraneeth nallapareddy
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thank you, it did worked.
but can you explain me why it needs to be done because i am already in the same location right.
 
Henry Wong
author
Posts: 23956
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

saipraneeth nallapareddy wrote:thank you, it did worked.
but can you explain me why it needs to be done because i am already in the same location right.




The classpath is used by the JVM to find the classes that it needs -- and since the class file is not in the jar file that you specified in the class path, you get an error condition.

In the case of the java compiler, it actually doesn't need the Seek class file. It is generating it.


As for being in the "same location" rule, that only applies when you don't set the class path -- the default class path. In your example, you set it, hence, there is no need to search the default class path.

Henry
 
saipraneeth nallapareddy
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks for the explanation it did really gave a useful point for me & where i can make a crystal clear about this point from my existing knowledge regarding this.
 
Marshal
Posts: 79637
380
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You may have to add a . for "current directory" to your system CLASSPATH; if however you set the system CLASSPATH all by yourself, you might be better without that environment variable altogether.
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
try

>set classpath=%classpath%;.;
>java your-classname

All the best
reply
    Bookmark Topic Watch Topic
  • New Topic