File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes java unable to recognize class where my IDE does Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "java unable to recognize class where my IDE does" Watch "java unable to recognize class where my IDE does" New topic
Author

java unable to recognize class where my IDE does

saipraneeth nallapareddy
Ranch Hand

Joined: Dec 02, 2009
Posts: 159
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
Sheriff

Joined: Sep 28, 2004
Posts: 18761
    
  40


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


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
saipraneeth nallapareddy
Ranch Hand

Joined: Dec 02, 2009
Posts: 159


Seek.java contains Seek class
and when i run it gives me this error.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19682
    
  20

Is class Seek perhaps member of a package?


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
saipraneeth nallapareddy
Ranch Hand

Joined: Dec 02, 2009
Posts: 159
no packages are used
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18761
    
  40


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

Henry
saipraneeth nallapareddy
Ranch Hand

Joined: Dec 02, 2009
Posts: 159
you mean to say
java -d . Seek
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18761
    
  40

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


java -cp %JMF_HOME%\lib\jmf.jar;. Seek
saipraneeth nallapareddy
Ranch Hand

Joined: Dec 02, 2009
Posts: 159
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
Sheriff

Joined: Sep 28, 2004
Posts: 18761
    
  40

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

Joined: Dec 02, 2009
Posts: 159
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

Joined: Oct 13, 2005
Posts: 38487
    
  23
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

Joined: May 28, 2010
Posts: 5
try

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

All the best


admin
www.javarecharge.com
||||||||||||||................
Wanna recharge
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java unable to recognize class where my IDE does