Objective: Client is Standalone java application. Our objective is the user will enter username from your client application,which will be passed to the service or EJB , which will return a String that composed of the  'Hello' suffixed with the entered name. Suppose you are entering Rajesh, the output would be

                       Hello Rajesh

These are the steps for achieving it

  1. Create on ejb project in eclipse  HelloUser-Services. (As Shown in previous example)
  2. Create one business interface like this
    package com.bullraider.ejb.business;
    import javax.ejb.Remote;
    @Remote
    public interface HelloUser {
        public String hello(String text);
    }
    
  3. Create Session Bean Class like this
    package com.bullraider.ejb.business;
    import javax.ejb.Stateless;
    @Stateless
    public  class HelloUserBean implements HelloUser{
    
    	public String hello(String hello) {
    		String name=hello;
    		return name;
    	}
    }
    Export this project as ejb.jar file to deploy folder of jboss as described in last examlpe

    This is the structure
  4. Create one java project HelloUser-StandaloneClient
    Create the main class HelloUserClient
    package com.bullraider.client.standalone;
    import java.util.Properties;
    import java.util.Scanner;
    import javax.naming.Context;
    import javax.naming.InitialContext;
    import javax.naming.NamingException;
    import com.bullraider.ejb.business.HelloUser;
    public class HelloUserClient {
    	public static void main(String[] args) {
    
    		Properties props = new Properties();
    		props.put("java.naming.factory.initial", "org.jboss.naming.HttpNamingContextFactory" );
    		props.put("java.naming.provider.url", "http://localhost:8080/invoker/JNDIFactory");
    		props.put("java.naming.factory.url.pkgs", "org.jboss.naming");
    
    		try {
    			Context context = new InitialContext(props);
    			try {
    				Scanner sc=new Scanner(System.in);
    				System.out.println("Please enter your name");
    				String userName=sc.next();
    				HelloUser helloWorld = (HelloUser)context.lookup("HelloUserBean/remote-com.bullraider.ejb.business.HelloUser");
    				System.out.println( helloWorld.hello("Hello   ")+ userName);
    
    			} 
    			catch (NamingException e) {
    				System.out.println("couldn't look up ");
    				e.printStackTrace();
    			}
    		} catch (NamingException e) {
    			System.out.println("naming exception occoured");
    			e.printStackTrace();
    		} 
    	}
    
    }
    
    

    This is the Structure
  5. Add the HelloUserServicess.jar which you have exported in deploy folder
    Add other required jar files
    This is the output

Download HelloUserServices.jar and HelloUserClient.jar