on 09-07-2007 8:41 AM
Hi Java Guru,
I am new in Java. However I have try to compile the Java program however i have this error massage as below. Can any Java Guru help me on this.
lai.java:7: package com.sap.mw.jco does not exist
import com.sap.mw.jco.*;
lai.java:17: package JCO does not exist
JCO.Client client = null;
............
Source code as below
/**
Example1.java
Property of SAP AG, Walldorf
(c) Copyright SAP AG, Walldorf, 2000.
All rights reserved.
*/
import com.sap.mw.jco.*;
/**
@version 1.0
@author SAP AG, Walldorf
*/
public class lai {
public static void main(String[] argv)
{
JCO.Client client = null;
try {
// Print the version of the underlying JCO library
System.out.println("\n\nVersion of the JCO-library:\n" +
"----
\n" + JCO.getMiddlewareVersion());
// Create a client connection to a dedicated R/3 system
client = JCO.createClient("xxx", // SAP client
"xx", // userid
"xx", // password
"EN", // language
"",// host name
"01"); // system number
// Open the connection
client.connect();
// Get the attributes of the connection and print them
JCO.Attributes attributes = client.getAttributes();
System.out.println("Connection attributes:\n" +
"----
\n" + attributes);
// Create the input parameter list
JCO.ParameterList input = JCO.createParameterList();
// Set the first (and only) import parameter
input.appendValue("REQUTEXT", JCO.TYPE_CHAR, 255, "This is my first Jayco example.");
// Create the out parameter list
JCO.ParameterList output = JCO.createParameterList();
// Specify the parameters types the function will be returning
output.addInfo("ECHOTEXT", JCO.TYPE_CHAR, 255);
output.addInfo("RESPTEXT", JCO.TYPE_CHAR, 255);
// Call the function
client.execute("STFC_CONNECTION", input, output);
// Print the result
System.out.println("The function 'STFC_CONNECTION' returned the following parameters:\n" +
"----
");
for (int i = 0; i < output.getFieldCount(); i++) {
System.out.println("Name: " + output.getName(i) + " Value: " + output.getString(i));
}//for
// Close the connection
client.disconnect();
// All done
System.out.println("\n\nCongratulations! It worked.");
}
catch (Exception ex) {
System.out.println("Caught an exception: \n" + ex);
if (client != null) client.disconnect();
}
}
}
Message was edited by:
Lord shadow
Hi,
Apart from adding this file in class path, you need to put the reqd dll file in system32 directory.
download sapjco-ntintel-2.0.5.zip from service.sap.com and put librfc32.dll & sapjcorfc.dll in
system32 directory.
It is used to connect to make the RFC call.
Regards
Pushkar
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi Lord Shadow,
you need the jco library to compile this class.
you can find it in http://service.sap.com/connectors -> SAP Java Connector
Download the archive for your environment and follow the installation instruction.
After this take the jar file contained in the library and put it into your classpath.
Best Regards
Francesco
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I suggest you to use the Eclipse ide to manipulate and compile your java code.
you can find it here: http://www.eclipse.org
If you compile the class manually you can specify your classpath in this way (considering that you putted your jar in this folder c:\javalibs)
javac -classpath c:\javalibs lai.java
Here a useful link to understand the classpath
http://en.wikipedia.org/wiki/Classpath_(Java)
Best Regards,
Francesco
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.