aspose file tools*
The moose likes Beginning Java and the fly likes java -cp question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "java -cp question" Watch "java -cp question" New topic
Author

java -cp question

Anthony Smith
Ranch Hand

Joined: Sep 10, 2001
Posts: 285
I am working with google apis.
I created a java file called mygoogle with no package and placed it directly in the root directory of my google folder. Also in the root directory of my google folder is the googleapi.jar file that is needed to compile and run mygoogle. I can compile mygoogle just fine but I cannot run it. From the google directory I do:
java -cp googleapi.jar mygoogle 1234PVQFHIpUjaP10MscjPLxgJQy1U5 search Foo
and I get:
Exception in thread "main" java.lang.NoClassDefFoundError: mygoogle
How do I get around that?
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9053
    
  12
In addition to including the jar, you need to also include your base directory in your classpath. For example,

java -cp C:\google\googleapi.jar;C:\google mygoogle 1234PVQFHIpUjaP10MscjPLxgJQy1U5 search Foo


JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
Praful Thakare
Ranch Hand

Joined: Feb 10, 2001
Posts: 641
Hi,
If u can also try this
java -cp C:\google\googleapi.jar;. mygoogle 1234PVQFHIpUjaP10MscjPLxgJQy1U5 search Foo


All desirable things in life are either illegal, banned, expensive or married to someone else !!!
Anthony Smith
Ranch Hand

Joined: Sep 10, 2001
Posts: 285
Thanks guys both worked!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java -cp question