Q
Problem solve Get help with specific problems with your technologies, process and projects.

Error connecting to SAP in Linux

The code sample submitted by this reader works in Windows but not Linux for connecting to the SAP system. Austin Sincock provides an answer.

I am trying to create a connection to SAP using the following piece of code:
JCO.Client mConnection = null;
try {
mConnection = JCO.createClient(this.client, // SAP
client
this.userName.toUpperCase(), // userid
this.password.toUpperCase(), // password
this.language.toUpperCase(), // language
this.hostName, // application server host name
this.system); // system number
mConnection.connect();
}catch (JCO.Exception jex) {
throw new Exception(jex.getMessage());
}catch(Exception ex){
throw new Exception("Exception occured while creating Connection to SAP.");
}

In Windows, I am able to connect to SAP system but when I execute the same in Linux environment I get the following exception:
"Exception in thread main java.lang.ExceptionInInitializerError: JCO.classInitialize(): Could not load middleware layer 'com.sap.mw.jco.rfc.MiddlewareRFC' default_cpc_mode"

I am using JDK 1.4.2 / RedHat Linux 8.0 / sapjco-linuxintel-2.1.2.

Where am I going wrong?
See my tip on deciphering JCO exceptions. In your case, make sure the environment variable LD_LIBRARY_PATH points to the directory where JCO was installed.

Dig Deeper on SAP Java and J2EE

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchERP

SearchOracle

SearchDataManagement

SearchAWS

SearchBusinessAnalytics

SearchContentManagement

SearchHRSoftware

Close