File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Running Client Application from Windows98 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Running Client Application from Windows98" Watch "Running Client Application from Windows98" New topic
Author

Running Client Application from Windows98

Alex Iordache
Ranch Hand

Joined: Mar 13, 2001
Posts: 62
I have a Win NT machine which EJB resides.I have got Windows 98 nd windows 95 m/c's connected to that NT m/c.
I made a login screen (using JFrame) in one of the client machines (Windows platform), from which one can login to my EJB application in the NT Server.
I am not able to connect ..
Please provide me the steps for doing that..and also the requiremnts..
Thx.
SandeepKumar
Greenhorn

Joined: Jul 09, 2001
Posts: 3
what do you mean by ejb resides on the NT server means some server is running on that PC which contains the deployed ejb. then connect to that server's JNDI and lookup for you bean by the name you have deployed the bean .
use this program as reference
import java.rmi.RemoteException;
import java.util.Properties;
import javax.ejb.CreateException;
import javax.ejb.RemoveException;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.rmi.PortableRemoteObject;

public class Client
{
private static final String JNDI_NAME = "LHome";
private static final String url = "t3://localhost:7001";
private LHome home=null;
public Client() throws NamingException
{
home = lookupHome();
}
public static void main(String[] args) throws Exception
{
log("\nBeginning statelessSession.Client...\n");
Client client = null;
try
{
client = new Client();
}
catch (NamingException ne)
{
System.exit(1);
}
try
{
client.example();
}
catch (Exception e)
{
log("There was an exception while creating and using the Trader.");
log("This indicates that there was a problem communicating with the server: "+e);
e.printStackTrace();
}
log("\nEnd statelessSession.Client...\n");
}
public void example() throws CreateException, RemoteException, RemoveException
{
// create a Trader
log("Creating a trader");
LRemote trader = (LRemote) narrow(home.create(), LRemote.class);
trader.printHelloWorld();
trader.remove();
// remove the Trader
log("Removing the trader ");
}
private Object narrow(Object ref, Class c)
{
return PortableRemoteObject.narrow(ref, c);
}
private LHome lookupHome()throws NamingException
{
Context ctx = getInitialContext();
try
{
Object home = ctx.lookup(JNDI_NAME);
return (LHome) narrow(home, LHome.class);
}
catch (NamingException ne)
{
log("The client was unable to lookup the EJBHome. Please make sure ");
log("that you have deployed the ejb with the JNDI name "+JNDI_NAME+" on the WebLogic server at "+url);
throw ne;
}
}
private Context getInitialContext() throws NamingException
{
try
{
// Get an InitialContext
Properties h = new Properties();
h.put(Context.INITIAL_CONTEXT_FACTORY,
"weblogic.jndi.WLInitialContextFactory");
h.put(Context.PROVIDER_URL, url);
h.put(Context.SECURITY_PRINCIPAL, "system");
h.put(Context.SECURITY_CREDENTIALS, "sandeepk");
return new InitialContext(h);
}
catch (NamingException ne)
{
log("We were unable to get a connection to the WebLogic server at "+url);
log("Please make sure that the server is running.");
throw ne;
}
}
private static void log(String s)
{
System.out.println(s);
}
}
 
 
subject: Running Client Application from Windows98