Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 17 May 2002 18:30:23 +0200
From:      "Amir Bukhari" <bukhari@fzi.de>
To:        "'Ernst de Haan'" <ernsth@nl.euro.net>, <freebsd-java@freebsd.org>
Subject:   AW: RMI and Thread with jdk1.3.1
Message-ID:  <000001c1fdc0$250be810$3b00a8c0@C39>
In-Reply-To: <200205170841.34641.ernsth@nl.euro.net>

next in thread | previous in thread | raw e-mail | index | archive | help
I use freebsd 4.5 StABLE.

this the java version I use linux-jdk1.3.1 :
java version "1.3.1_02"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1_02-b02)
Classic VM (build 1.3.1_02-b02, green threads, nojit).

Note : I have also tried the port jdk1.3.1p5

Sorry but I cant put the source code, because it very big ( more than
3000 lines), but I can put
the main class, which provide RMI. I have build it with javac

I know that java is independet plattform, therefor my programm should
work also under freebsd,
 that mean there something wrong with my installation or I have missing
to install something, there is a
configuration I must do before using java,
 but I have installed java from the port collection, which install also
dependeries.

My main Program (Server) do the following:
1- run RMI Regestry at port 1099
2- then wait for a connection from the client, which a specified
command.
3- when it received command from the client it then start the simulation
Program, which should be run as Thread.

Clien Site:
the client only send the command to the server.

Source code :
import java.rmi.*;
import java.rmi.server.*;
import java.rmi.registry.*;
import java.util.*;
import java.net.*;

class RMISimServerImpl extends UnicastRemoteObject
        implements RMISimServerInterface
{
  int STOP =3D 1, START =3D 2 , PAUSE =3D 3, QUIT =3D 4, CONTINUE =3D 5;
  RMISimProtokol protokol =3D new RMISimProtokol();
  EventSimPar arg =3D new EventSimPar();
  String modell;
  int cmd =3D -1;

  public RMISimServerImpl() throws RemoteException {}

  public RMISimServerImpl(String filename, EventSimPar argument) throws
RemoteException {
    modell =3D filename;
    arg =3D argument;
  }

  public void SendCommand(int command) throws RemoteException
  {
    cmd =3D command;

    System.out.println("Command was Send"); // as Tes, but this was not
displayed when i have sended a command !!
  }

  public void SendEvent(RMIEvent rmievent) throws RemoteException
  {
    protokol.SetEvent(rmievent);
  }
  public void prozessCommand() {
    int command =3D -1;
    //System.out.println("Waiting for command");
    while(command =3D=3D -1) {

      if (cmd =3D=3D START) {
        protokol.SetCommand(cmd);
        EventSim evtSim =3D new EventSim(modell, arg); // this is The
Simulation Programm which run as Thread
        evtSim.start();
        cmd =3D -1;
      } else if (cmd =3D=3D QUIT) {
       protokol.SetCommand(cmd);
       command =3D 0;
      } else if (cmd =3D=3D STOP) {
        protokol.SetCommand(cmd);
      }else if (cmd =3D=3D PAUSE) {
        protokol.SetCommand(cmd);
      }else if (cmd =3D=3D CONTINUE) {
        protokol.SetCommand(cmd);
      }

    }
    System.exit(0);
  }
  public void runRMI() {
     //System.out.println("Ready for RMI's ");
     //System.setSecurityManager(new RMISecurityManager());
     try {
       System.out.print("Registering RMISimServer");
       //RMISimServerImpl rmiserver =3D new RMISimServerImpl();
       LocateRegistry.createRegistry(1099);
       Naming.bind("rmi://:1099/RMISimServerImpl",this);
       System.out.println("   Done.");
     } catch (Exception e) {
        System.out.println(e.toString());
        System.exit(1);
     }


    prozessCommand();

  }
}

class RMISimProtokol
{
   static int command =3D -1;
   int STOP =3D 1, START =3D 2 , PAUSE =3D 3, QUIT=3D 4;
   RMIEvent rmiEvent;
   static Queue inputVectors =3D new Queue();

   public RMISimProtokol() {}

   public void SetCommand(int cmd) {
      command =3D cmd;
  }
  public void SetEvent(RMIEvent rmievnt)
  {
    rmiEvent =3D rmievnt;
    inputVectors.enqueue(rmievnt);
  }

  public RMIEvent GetEvent() {
      RMIEvent result =3D null;
      try {
        if(!inputVectors.isQueueEmpty())
          result =3D (RMIEvent) inputVectors.dequeue();
      } catch (Exception e) {
        System.out.println("GetEvent error: " + e.toString());
      }
      return result;
  }


  public int getCommand() {
     return command;
  }
}

> -----Urspr=FCngliche Nachricht-----
> Von: Ernst de Haan [mailto:ernsth@nl.euro.net]
> Gesendet: 17 May, 2002 08:42 =D5
> An: Amir Bukhari; freebsd-java
> Betreff: Re: RMI and Thread with jdk1.3.1
>=20
> Amir,
>=20
> If you want people to help you, you will need to provide more detailed
> information:
> 1) FreeBSD version (Use 'uname -a')
> 2) Java version (Use 'java -version')
> 3) A test case, if possible. Perhaps you can provide the source code
to
> the
> server and client programs with an Ant build file or so?
>=20
> Ernst
>=20
> On Friday 17 May 2002 00:14, Amir Bukhari wrote:
> > Hi,
> > I am a new user of FreeBSD; therefore I have no experience with
FreeBSD
> > fundamental.
> > Ok, I have Install Java 1.3.1 and I have tested it with a program,
which
> > I have written under Linux,
> > But It seem to it is not working, this program implement RMI and
Thread
> > in Java. It Contain Server and Client program.
> > Under windows, Linux, Solaris work very good, but under FreeBSD not
work
> > correctly "this mean it run but not give any output which  I wait
for
> > it"
> >
> >
> > If someone has an idea about this or similar, please E-Mail me.
> >
> > Amir
>=20
> --
> Ernst de Haan
> EuroNet Internet B.V.
>=20
>     "Come to me all who are weary and burdened
>         and I will give you rest" -- Jesus Christ


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-java" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?000001c1fdc0$250be810$3b00a8c0>