Distributed systems


Q: Has anyone ever tried anything like this or am I asking for trouble trying to write a
program like this?....
I plan to use JBuilder to create a Java GUI that will use Perl to invoke system calls.
The GUI will be run in Windows(NT) while the system calls will be invoked in Unix.
Answer: Sure, why not? Seems to me it should be quite doable. Use Java code to build the GUI
and cross the network (for instance using RMI), then invoke the Perl interpreter as an external
process, or possibly use JPerl (see http://www.perl.com/CPAN-local/authors/id/S/SB/SBALA/ )
from there. Or use a different distributed objects architecture to connect Java and Perl objects
over the network...
About serialization...
If I have a class that implements the Serializable interface, but it has member variables which
reference objects that do not implement the Serializable interface, it appears that I can't
serialize an instance of the class. I keep getting:
java.io.NotSerializableException
for one of the objects referenced by a member variable.
Am I correct, or am I just missing something. Also, if anyone knows a work-around to serialize
non-serializable objects, I'd like to hear about it. Unfortunately, I have no control over the
classes I'm trying to serialize, so I tried putting a serializable wrapper around them , but that

didn't work.
Answer: Do you really need to serialize those members of your class which aren't serializable?
In other words, make them private:
class Foo implements Serializable {
private Bar bar;
}
Do you *need* to maintain the state of the 'bar' variable when serializing/deserializing Foo? If
not, simply declare 'bar' as 'transient' and it will be ingored during serialization.
RMI versus Socket communication
I wish to get Java talking to C++ across a network.
Does anyone have any thoughts in terms of performance, ease of development etc.
in :
Wrapping the C++ side with JNI and using RMI for the communications.
versus
Writing sockets code and communicating via http?
Answer: It depends of what kind of application you're writing but l think about
the following :
- with RMI you can have remote REFERENCE instead of having to transfer all the object
through the network. The object has just to implement Remote. So it spare bandwith and is
good for performance. This is impossible to do if you do through a socket connection, you've to
send the all object.


- You've not to take in charge the serialization (which could be not so easy depending of your
object structure), neither the connections, etc... All of that is taken in charge by RMI.
- the performance are GOOD (even a bit more than that)
three good points to use RMI, isn't it?
The difficulty added by RMI is the configuration of both client and server (distribution of stubs,
rmiregistry, what's happen if firewall). Depending of the environment all of that can be either
easy or complicate.
But once that all of that is in place you can extend your application
easily, so it's much more flexible and scalable.
If your needs are small perhaps that you could do your own connection system (but for me it's
less scalable and more bandwith consuming and so less performant).
--
François Malgrève
Answer 2: I have done both. If your communication scenarios are diverse and could keep
changing, using a remote technology like RMI can help. If the operations are few and/or not
likely to change you can save the JNI complexity. Not that it is really hard it just can be fun
keeping the JNI code in sinc with the C++ code.

Q: I need to communicate some data (string) from a Java Applet to an other ASP page in
the same frameset. I would like to avoid a server roundtrip and do it all with JavaScript if
possible.
Therefore I would like to call some javascript from a Java Applet. It looks like it is not possible
without a netscape package. Is that true? Is there a simple implementation of the same
functionality (source code) which I could incorporate in my applet?
Answer: Those Netscape packages are part of the current VM of both Microsoft IE 4+ and
Netscape 4+. So, by adding the MAYSCRIPT tag to your Applet declaration, in the Java code
you can obtain a handle to the document and call functions in it.
Q: I'm researching methods by which one JVM can interact with another JVM, which is
running on the same machine.
I know that there are various network models, which can be applied if a JVM needs to talk to
another one across a network, but in addition to these (which could I guess be applied to JVMs
on the same machine) I wondered if you knew of a system of JVM communication that requires
less system resources, where the JVMs are both running on the same system.
Answer: CORBA, RMI, HTTP, sockets....
But if you have no TCP/IP stack on your platform, so for Windows it could be clipboard...
--
by dmitry

Q: I have a question about sending a reference to the object via the socket...
I have a question about sending a reference to the object via the socket. Two threads are
communicating via sockets running on the same machine. I don't need to send the whole
object, but I need to send just
a reference.
Does anyone knows how to do that?
Answer: Reference to an Object? A reference is only valid within the same memory space! If
you want to be able to invoke methods on an object remotely, then you will need to use a
remote technology like RMI, CORBA, or some such.
--