Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Package doesnot exist

 
feda alshahwan
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am creatig a small client java program and i am importing some classes but i had errors during compilation, the error is that cannot find the package! How to find it ?where to put it?This is my code:

import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import javax.xml.namespace.QName;

public class Client {
public static void main(String [] args) {
try {
String endpointURL =
"http://localhost:8080/axis/services/SilverService";

Integer in = new Integer(10);
Service service = new Service();
Call call = (Call) service.createCall();

call.setTargetEndpointAddress(
new java.net.URL(endpointURL) );
call.setOperationName(
new QName("SilverService", "getIncrement") );

Object ret = call.invoke( new Object[] { in } );

System.out.println("Object = " + ret.getClass().getName());
System.out.println("Number Returned : " + ret.toString());
} catch (Exception e) {
System.err.println(e.toString());
}
}
}
 
Mark Vedder
Ranch Hand
Posts: 624
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It would be helpful if you could post the full error message. (And it is generally a good idea to do such when posting questions. - See the TellTheDetails tip for more information.)

Most likely your issue is that the package that is not being found in not on your classpath. So most likely you need to adjust your classpath. If its the org.apache.axis.client package not being found, you need to add the Apache Axis JAR to your classpath. (If you are not sure how to do that, let us know and we can show you.) But depending on the error message you are getting, there may be other things you may need to do.
[ August 04, 2008: Message edited by: Mark Vedder ]
 
Rob Spoor
Sheriff
Pie
Posts: 20495
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to include the Axis JAR file in the classpath when compiling. javax.xml.namespace.QName won't be a problem if you're using Java 5.0 or higher.
 
feda alshahwan
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear
Thank you for your response.I am using NetBeans. How to include a classpath using NetBeans?
When I used JDK1.5.0_16 from command line I got the following:


C:\tomcat50-jwsdp\tomcat50-jwsdp\webapps\axis\WEB-INF\classes>javac -cp %AXISCLA
SSPATH% %AXIS_HOME%\web-inf\classes\Client\src\client\Client.java
C:\TOMCAT50-JWSDP\TOMCAT50-JWSDP\WEBAPPS\AXIS\web-inf\classes\Client\src\client\
Client.java:10: java.security.Provider.Service is already defined in a single-ty
pe import
import org.apache.axis.client.Service;
^
C:\TOMCAT50-JWSDP\TOMCAT50-JWSDP\WEBAPPS\AXIS\web-inf\classes\Client\src\client\
Client.java:20: cannot find symbol
symbol : constructor Service()
location: class java.security.Provider.Service
Service service = new Service();
^
C:\TOMCAT50-JWSDP\TOMCAT50-JWSDP\WEBAPPS\AXIS\web-inf\classes\Client\src\client\
Client.java:21: cannot find symbol
symbol : method createCall()
location: class java.security.Provider.Service
Call call = (Call) service.createCall();
^
3 errors

C:\tomcat50-jwsdp\tomcat50-jwsdp\webapps\axis\WEB-INF\classes>
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic