cancel
Showing results for 
Search instead for 
Did you mean: 

SAPJco 3.0.2 - Simple connection test

Former Member
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

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

Answers (1)

Answers (1)

Former Member
0 Kudos

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

Former Member
0 Kudos

Thanks Vivek, but thats' been done. I added the 'jrfc.jar' as an external jar which I locatated in ...\com.sap.tc.ap_2.0\comp\SAP-JEE\DCs\...jrfc.jar. Perhaps that's the problem? Should I be looking elsewhere?

Kevin

Former Member
0 Kudos

Hello there,

Also you need to place the DLLs in the folder C:\WINDOWS\system32\drivers folder. How you dont this step ?

Regards,

Vivek

Former Member
0 Kudos

Yes, well I checked first and there was 'librfc32.dll' already there in System32. But you mentioned DLL's, I was aware of only that one, are there others that need to be there?

Former Member
0 Kudos

Hello there,

The DLL need to be one which you downloaded from http://service.sap.com/connectors.

Regards,

Vivek Nidhi

Former Member
0 Kudos

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

Former Member
0 Kudos

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?