aspose file tools*
The moose likes Beginning Java and the fly likes Compile from cmd is not working while from IDE is working Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Compile from cmd is not working while from IDE is working " Watch "Compile from cmd is not working while from IDE is working " New topic
Author

Compile from cmd is not working while from IDE is working

Maha Hassan
Ranch Hand

Joined: Aug 02, 2005
Posts: 133
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

Joined: Feb 07, 2005
Posts: 2367
It sounds like a problem with your CLASSPATH.

If you try java -cp . Tool, what happens?
Maha Hassan
Ranch Hand

Joined: Aug 02, 2005
Posts: 133
that what happens

Jesse Wilson
Greenhorn

Joined: Jul 15, 2006
Posts: 3
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 ]

To be, or not to be?... This is no longer the question.
Maha Hassan
Ranch Hand

Joined: Aug 02, 2005
Posts: 133
well that has worked ...so what shall i do to fix it ?
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14114
    
  16

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 ]

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
 
Don't get me started about those stupid light bulbs.
 
subject: Compile from cmd is not working while from IDE is working