Shared Library example for Oracle Weblogic Server

1. Compile your code and package it in a jar file. In this example I have written a simple program that has a function that just takes a string as input and prints hello infront of the string.


package wonders;

public class MyTestClass

static {
System.out.println("MyTestClass class Loaded From sf1.jar");

public String sayHello(String name)
System.out.println("sf1.jar sayHello() called"); ;
return name;


2. Deploy the jar file on the server as a library.

3. Refer the shared library in the weblogic-application.xml present under EARMETA-INF folder.


<?xml version="1.0" encoding="ISO-8859-1"?>

<weblogic-application xmlns="” 



4. Access the library from your application. In my example I am calling the function from a jsp.

 <body> Hi this is hello from sl1.jar<BR> 
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1" import="wonders.*" %>
 <% wonders.MyTestClass mtc=new wonders.MyTestClass(); 
 System.out.println("Hello to "+ mtc.sayHello("Wonders")); %> 


shared library


shared library1