简体   繁体   中英

Java classpath setting error

I am getting "could not find or load main class" error even though i am setting the class path correctly.

Here is my directory structure:

 src\org\apache\ws\axis2

Inside axis2 directory, i have my Client.class file.

Now, to run the Client class file, i gave the following command from src directory

java -cp "C:\Documents and Settings\F1QBWFA\My Documents\Downloads\temp\src\org\apache\ws\axis2" org\apache\ws\axis2\Client

I tried this as well:

java -cp "C:\Documents and Settings\F1QBWFA\My Documents\Downloads\temp\src\org\apache\ws\axis2" org.apache.ws.axis2.Client

And i get the same error. What am i doing wrong here?

Shouldn't it be

java -cp "C:\Documents and Settings\F1QBWFA\My Documents\Downloads\temp\src" org.apache.ws.axis2.Client

Class path should refer to the root of your package structure, not to the specific folder of the inner package. Of course I'm assuming you have package org.apache.ws.axis2; at the beginning of Client.java

As it implies, the classpath is set to a path where you can find, well, classes

I think you might be having classes stored in the bin or the classes directory.

Change your command line to:

java -cp "C:\\Documents and Settings\\F1QBWFA\\My Documents\\Downloads\\temp\\classes" org.apache.ws.axis2.Client

If you have the classes alongside src, then change it to

java -cp "C:\\Documents and Settings\\F1QBWFA\\My Documents\\Downloads\\temp\\src" org.apache.ws.axis2.Client

Classpaths should only be set till the root of the package.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM