views:

166

answers:

10

I know that the Java can use the Socket Programming to send an Object. Apart from socket programming, anything other way to do it?

+1  A: 

Via web service for example. But its build on top on sockets again.

NikolayGS
Yes web services are build on sockets but you don't have to work with them directly.
backslash17
+7  A: 

Java's Remote Method Invocation (RMI) is probably the easiest and most widely supported way.

Java's Advanced Socket Programming describes marshalling objects over a socket.

Eric Petroelje
Using RMI (Remote Method Invocation) is probably an overkill and of course does involve sockets again.
Murali VP
Why is this overkill ? This seems entirely reasonable to me. I take your point about sockets, but (as everyone has pointed out) doing this *without* sockets seems a little, well, peculiar.
Brian Agnew
Aside from high speed robotic hands, carrier pigeons , rubber bands, or sneakernet, any practical way of sending data from one computer to another will involve sockets in some way or another. It's just a mater of how well abstracted you are from the actual socket.
Eric Petroelje
@Brian Agnew, because RMI has a gross API. :)
NateS
+4  A: 

RFC1149!

just somebody
While faster than sockets in some countries, I'd guess it isn't very practical :)
Eric Petroelje
What a bird-brained idea. ;-)
Dave Jarvis
what, it's language-agnostic!
just somebody
RFC is from 1990! and hosted by IETF itself!
Murali VP
updated by RFC 2549: http://tools.ietf.org/html/rfc2549
Carlos Heuberger
+1  A: 

SOAP (Simple Object Access Protocol).

backslash17
+5  A: 

Control a high-speed robot hand to type it in.

Pretty well every other thing you can do will be a layer built on sockets.

Pete Kirkham
Incredible hand! whoao!
backslash17
+1  A: 

Serialize the object, write to a file, copy the file if the computers are network connected if not use a removable disk and deserialize it.

Murali VP
+2  A: 
  1. Attach rubber band to computer A
  2. Put Object in rubber band.
  3. Pull back, aim at Computer B.
  4. Let go.
Larry Watanabe
+1  A: 

Objects can be transferred via a shared database.

I work near a production system that's been doing this for 10 years.

Ironically, except in rare cases, DB connections are also implemented via sockets.

Carl Smotricz
A: 

No. Sockets are how computers communicate. Other than writing the data to some media and physically transporting it between computers, you will have to use sockets.

At the lowest level, data is transferred over sockets as bytes. So first you need to serialize your object to bytes, then you can send it, then on the other side you need to deserialize the object from the bytes.

Approaching your question less literally, there are Java libraries that handle the serialization automatically and hide the nastiness of dealing directly with sockets. I recommend KryoNet. KryoNet can do remote method invocations, and a lot simpler and more efficiently than Java's built-in RMI support.

NateS
A: 

I wrote a blog post on how to send objects from Java to .NET. You can use the same technique to send objects between applications on the same platform.

http://ferozedaud.blogspot.com/2009/11/how-to-send-object-from-java-to-net.html

feroze