• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

java unable to recognize class where my IDE does

 
saipraneeth nallapareddy
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
  • 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.
 
Henry Wong
author
Marshal
Pie
Posts: 21220
81
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator


Seek.java contains Seek class
and when i run it gives me this error.
 
Rob Spoor
Sheriff
Pie
Posts: 20555
57
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
no packages are used
 
Henry Wong
author
Marshal
Pie
Posts: 21220
81
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
you mean to say
java -d . Seek
 
Henry Wong
author
Marshal
Pie
Posts: 21220
81
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • 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
  • 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
Marshal
Pie
Posts: 21220
81
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • 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
  • 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.
 
Campbell Ritchie
Sheriff
Pie
Posts: 49466
64
  • Mark post as helpful
  • send pies
  • 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.
 
getshijos joseph
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
try

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

All the best
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic