How to call a JCo through a Java applet

How to call a JCo through a Java applet

Executing a Java applet throws an exception when run through Internet Explorer. In the Eclipse environment, the applet works perfectly; logs on to R/3 with my user I.D. and password and executes a simple function module. It then returns back some parameter text and logs off. In Internet Explorer, when executing the HTML file, I get the following error message:

java.lang.NoClassDefFoundError.

How do I call JCo through a Java applet?

    Requires Free Membership to View

    When you register, you will start receiving targeted emails from my award-winning team of editorial writers. Our goal is to keep you informed on the hottest topics and biggest challenges faced by SAP professionals today.

    Hannah Smalltree, Editorial Director

    By submitting your registration information to SearchSAP.com you agree to receive email communications from TechTarget and TechTarget partners. We encourage you to read our Privacy Policy which contains important disclosures about how we collect and use your registration and other information. If you reside outside of the United States, by submitting this registration information you consent to having your personal data transferred to and processed in the United States. Your use of SearchSAP.com is governed by our Terms of Use. You may contact us at webmaster@TechTarget.com.

The problem lies with the fact that your applet class cannot 'see' the sapjco.jar file. Because the applet runs in its own container, it does not have access to the local CLASSPATH variable set by your operating system. There are two mechanisms to make the sapjco.jar file visible to the applet.

The easiest way to do this is to copy the sapjco.jar file into the "lib/ext" directory underneath your Java JRE home directory. Find the JRE/lib/ext directory in the directory where you installed the Java JDK. Copy sapjco.jar here, then restart your applet.

The second mechanism would be used for deploying your applet to a wider audience across your network. In that case, you would need to physically store the sapjco.jar file on the Web server that will be hosting your applet. This should be contained in the same directory in which your applet is being deployed (for more information perform a Google search for "deploying applet as war"). You will also need to specify where the applet can find this jar using the CACHE_ARCHIVE attribute in the applet tag of the HTML document used to deploy the applet. Set the CACHE_ARCHIVE attribute equal to the local path on the server where sapjco.jar can be found (ex. PARAM NAME="CACHE_ARCHIVE" VALUE="/webserver/jcodirectory/sapjco.jar").

This was first published in July 2006