Getting "java.lang.UnsatisfiedLinkError: no sapjco3 in java.library.path" error using SAP jco 3.0.11 for 32 bit windows

Rohit Sharma picture Rohit Sharma · Sep 23, 2014 · Viewed 10.6k times · Source

I am getting the below mentioned error while using SAPJCO 3.0.11 jar for 32 Bit windows XP OS. I am using a StepByStepClient example mentioned in the zip libarary when i downloaded the 32 but SAPJCO jar from market place. The Jar I downloaded never had a dll file for 32 bit system. please let me kow what i am missing and please help me to get this issues resolved.

Below is the error:

ava.lang.UnsatisfiedLinkError: no sapjco3 in java.library.path
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1886)
    at java.lang.Runtime.loadLibrary0(Runtime.java:849)
    at java.lang.System.loadLibrary(System.java:1088)
    at com.sap.conn.jco.rt.DefaultJCoRuntime.loadJCoLibrary(DefaultJCoRuntime.java:772)
    at com.sap.conn.jco.rt.DefaultJCoRuntime.registerNativeMethods(DefaultJCoRuntime.java:382)
    at com.sap.conn.jco.rt.JCoRuntime.registerNatives(JCoRuntime.java:1200)
    at com.sap.conn.rfc.driver.CpicDriver.<clinit>(CpicDriver.java:792)
    at com.sap.conn.rfc.engine.DefaultRfcRuntime.getVersion(DefaultRfcRuntime.java:36)
    at com.sap.conn.rfc.api.RfcApi.RfcGetVersion(RfcApi.java:238)
    at com.sap.conn.jco.rt.MiddlewareJavaRfc.<clinit>(MiddlewareJavaRfc.java:217)
    at com.sap.conn.jco.rt.DefaultJCoRuntime.initialize(DefaultJCoRuntime.java:98)
    at com.sap.conn.jco.rt.JCoRuntimeFactory.<clinit>(JCoRuntimeFactory.java:23)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:190)
    at com.sap.conn.jco.JCo.createJCo(JCo.java:52)
    at com.sap.conn.jco.JCo.<clinit>(JCo.java:26)
    at com.sap.conn.jco.JCoDestinationManager.getDestination(JCoDestinationManager.java:77)
    at com.sap.connect.StepByStepClient.step1Connect(StepByStepClient.java:91)
    at com.sap.connect.StepByStepClient.main(StepByStepClient.java:358)
Exception in thread "main" java.lang.ExceptionInInitializerError: JCo initialization failed with java.lang.UnsatisfiedLinkError: no sapjco3 in java.library.path

Thanks, Rohit

Answer

Diego Queiroz picture Diego Queiroz · Jul 18, 2017

First, and despite this connector is designed for Java, you should be aware that SAP Java Connector is not platform independent. You should have guessed it because there are different download links for each architecture in SAP's website.

So, the SAP Java Connector consists basically of two parts:

  • a sapjco3.jar file, for the java binding (platform independent).
  • a native library (an .so-file or .dll-file) for the platform specific binding.

To make your application work, just assure that both files are in the PATH (or CLASSPATH) of your app, and you're done.

If you're under Windows, copying the .dll file to \Windows\System32 will work, but a puppy dies every time you do so. If you love puppies, don't do that. Ever.

Better yet, it would be to always read the documentation. This is really a very good practice. The docs for SAP Java Connector 3.0 clearly states the following:

SAP Java Connector 3.0 :: Installation

...

Microsoft Windows

...

Note: Do not copy the sapjco3.dll neither into the {windows-dir}\system32 nor into the {windows-dir}\SysWOW64 directory. This will break the operability of other JCo versions that are already installed on the same system. Furthermore you would risk that the current installation also would not work anymore, if the sapjco3.dll gets replaced in the respective Windows system directory in the future.

  • Then add {sapjco3-path} to the PATH environment variable.
  • Finally, add {sapjco3-path}\sapjco3.jar to your CLASSPATH environment variable.

...

This means SAP developers love puppies.