Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Compile from cmd is not working while from IDE is working

 
Maha Hassan
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

This might sound strange but i am trying to run something from the commande promt and it is not running but when i compie it using jcreator it works..
I am sure that i am in the right directory sice i used dir command and i have seen all files but still it getms me this strange error??
what shall i do ??

Maha

Z:\Java Files\Xpath>dir
Volume in drive Z is ??
Volume Serial Number is 0BAD-0207

Directory of Z:\Java Files\Xpath

07/18/2006 01:40 PM <DIR> .
07/18/2006 12:19 PM <DIR> ..
07/14/2006 11:48 AM 895 XPathHelper.java
07/18/2006 12:24 PM <DIR> com
07/17/2006 10:42 AM 1,759 TransformationApp.java
07/12/2006 01:55 PM 137 candy.xml
07/17/2006 10:57 AM 1,652 TransformationApp.class
07/18/2006 01:26 PM 1,157 erd.java
07/17/2006 12:00 PM <DIR> org
07/18/2006 01:34 PM 1,382 exec.java
07/18/2006 01:35 PM 1,226 exec.class
07/17/2006 09:53 AM 7,666 Tokenize.java
07/18/2006 12:24 PM 4,851 Tokenize.class
07/13/2006 01:57 PM 215 candy1.dtd
07/18/2006 01:02 PM 448 interf.java
07/18/2006 01:32 PM 504 ListNodeList.java
07/18/2006 01:32 PM 636 ListNodeList.class
07/18/2006 01:26 PM 1,049 erd.class
07/18/2006 01:34 PM 194 candy.dtd
07/18/2006 01:40 PM 826 Tool.java
07/18/2006 01:41 PM 1,234 Tool.class
17 File(s) 25,831 bytes
4 Dir(s) 1,073,610,752 bytes free

Z:\Java Files\Xpath>java Tool
Exception in thread "main" java.lang.NoClassDefFoundError: Tool

Z:\Java Files\Xpath>
 
Keith Lynn
Ranch Hand
Posts: 2409
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It sounds like a problem with your CLASSPATH.

If you try java -cp . Tool, what happens?
 
Maha Hassan
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
that what happens

 
Jesse Wilson
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Keith Lynn:
It sounds like a problem with your CLASSPATH.

If you try java -cp . Tool, what happens?


From the text you posted mate it looks like you entered "java -cp" at the prompt.

Try typing the following: Java -cp . Tool

You have to put the "." in there between the -cp and Tool. The dot basicly specifys that the current directory, which is represented by the dot ., (The dot represents "current directory")is the classpath you want to use.


Hope this helps!

If anything in this post is incorrect please correct me.... I'm a greenhorn myself. Only been learning Java for about five days now... so I could be really off, hope not though! :roll:
[ July 18, 2006: Message edited by: Jesse Wilson ]
 
Maha Hassan
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
well that has worked ...so what shall i do to fix it ?
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15359
39
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is already fixed, isn't it?

With the "-cp" option, you set the classpath, which means you tell Java where to look for class files. The "." dot indicates the current directory. So with "-cp ." you tell Java to look for class files in the current directory.

If you don't like typing "-cp ." every time, you can do one of two things:

1. Make sure that the CLASSPATH environment variable is not set (Java will use the current directory by default if it's not set).
2. Make sure that you add "." to the CLASSPATH environment variable.

More info:

Setting the class path
How Classes are Found
[ July 19, 2006: Message edited by: Jesper Young ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic