Skip to Content
avatar image
Former Member

SAPJco 3.0.2 - Simple connection test

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    avatar image
    Former Member
    Sep 30, 2009 at 09:40 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • Sep 24, 2009 at 04:19 PM

    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

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Vivek Nidhi

      The 'sapjco3.dll' was not in the system32 folder. I copied it there. Also the current version of java is 1.6 so I should be good. I'm still getting the same error. I restarted NWDS after I copied the DLL into the folder. Should I do something else?