on 09-24-2009 4:04 PM
Hi, I'm new to Java. I've read through the forum to see if this basic question was raised and solved. I can't see it so I'm guessing it's so simple that no one raised it before. I just installed the SAPJco 3.0.2 on my windows xp client. As per the documentation I added the ..\sapjco3-ntintel-3.0.2 to both the Path and CLASSPATH variables. I also ran the command line test -jar c:\..\sapjco3-ntintel-3.0.2\sapjco3.jar and got the resultant SAP screen with the info. Great, so far so good. I then go into NWDS(Eclipse) and create a new test class to test the connectivity to ECC6.0. Here is the code.
import com.sap.mw.jco.*;
public class SapRfcCall {
public static void main(String[] args) {
JCO.Client mConnection;
try {
mConnection = JCO.createClient("301", // SAP client
"somecoolguy", // userid
"****", // password
"EN", // language
"XXX", // application server host name
"00"); // system number
mConnection.connect();
System.out.println(mConnection.getAttributes());
mConnection.disconnect();
} catch (Exception ex) {
ex.printStackTrace();
System.exit(1);
}
}
}
Of course when I run it as an application I consistently receive these unpleasant errors
java.lang.NoClassDefFoundError
at com.sap.mw.jco.MiddlewareJRfc$Client.connect(MiddlewareJRfc.java:1018)
at com.sap.mw.jco.JCO$Client.connect(JCO.java:3255)
at sapRFCcall.main(sapRFCcall.java:34)
Exception in thread "main"
Do anyone have any suggestions as to how something so seemingly simple can go so wrong?
Thanks in advance,
Kevin
Hey Kevin,
Looking at your coding I think you just ran into a simple version problem. I.e. you're talking about SAP JCo 3.x, yet your coding is clearly requiring a JCO 2.x.
Note that SAP made some major API changes from JCo version 2.x to version 3.x. As a result coding that compiles and is valid for 2.x is no longer valid for 3.x. The API for 3.x is much cleaner though, so I suggest switching to JCo 3.x (see coding examples provided by SAP for simple RFC clients). Doesn't make much sense to start with 2.x now if you haven't used it before...
Best wishes, harald
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello there,
Right Click on the Project select properties Select Java Build Path. Add the jars to the project by clicking on Add External Jars.
Please try this and let me know
Regards,
Vivek Nidhi
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello there,
The DLL need to be one which you downloaded from http://service.sap.com/connectors.
Regards,
Vivek Nidhi
Also few more points
1) Please make sure you are using the correct 32 or 64 bit JCO based on your machine
2) The correct JVM version to support the JCO.
These details are available at http://service.sap.com/connectors
-Vivek
User | Count |
---|---|
84 | |
25 | |
12 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.