• 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
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

Compile from cmd is not working while from IDE is working

 
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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>
 
Ranch Hand
Posts: 2412
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
that what happens

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
well that has worked ...so what shall i do to fix it ?
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic