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 = 1, START = 2 , PAUSE = 3, QUIT = 4, CONTINUE = 5;
RMISimProtokol protokol = new RMISimProtokol();
EventSimPar arg = new EventSimPar();
String modell;
int cmd = -1;
public RMISimServerImpl() throws RemoteException {}
public RMISimServerImpl(String filename, EventSimPar argument) throws
RemoteException {
modell = filename;
arg = argument;
}
public void SendCommand(int command) throws RemoteException
{
cmd = 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 = -1;
//System.out.println("Waiting for command");
while(command == -1) {
if (cmd == START) {
protokol.SetCommand(cmd);
EventSim evtSim = new EventSim(modell, arg); // this is The
Simulation Programm which run as Thread
evtSim.start();
cmd = -1;
} else if (cmd == QUIT) {
protokol.SetCommand(cmd);
command = 0;
} else if (cmd == STOP) {
protokol.SetCommand(cmd);
}else if (cmd == PAUSE) {
protokol.SetCommand(cmd);
}else if (cmd == 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 = 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 = -1;
int STOP = 1, START = 2 , PAUSE = 3, QUIT= 4;
RMIEvent rmiEvent;
static Queue inputVectors = new Queue();
public RMISimProtokol() {}
public void SetCommand(int cmd) {
command = cmd;
}
public void SetEvent(RMIEvent rmievnt)
{
rmiEvent = rmievnt;
inputVectors.enqueue(rmievnt);
}
public RMIEvent GetEvent() {
RMIEvent result = null;
try {
if(!inputVectors.isQueueEmpty())
result = (RMIEvent) inputVectors.dequeue();
} catch (Exception e) {
System.out.println("GetEvent error: " + e.toString());
}
return result;
}
public int getCommand() {
return command;
}
}
> -----Ursprüngliche Nachricht-----
> Von: Ernst de Haan [mailto:ernsth@nl.euro.net]
> Gesendet: 17 May, 2002 08:42 Ő
> An: Amir Bukhari; freebsd-java
> Betreff: Re: RMI and Thread with jdk1.3.1
>
> Amir,
>
> 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?
>
> Ernst
>
> 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
>
> --
> Ernst de Haan
> EuroNet Internet B.V.
>
> "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>
