how to call a remote java class(method) - java

I have a java based software and my client wants to load some data to the software using a different tool. I need to write a java module that can speak with both and acts as a mediator. How do I pass inputs from 3rd party tool to the my java based software?
If I could invoke any class(in java based software) from eclipse using the remote invocation then it would suffice my need.
I have never worked on remote invocation.

Well, you could look into using Java RMI.
However, this is usually done with Web Service http calls now.
I think most people would recommend using a RESTful solution and passing JSON representations of your objects back and forth between the two distributed systems.

Related

How do I know whether to use standard Java networking or Java RMI?

I'm debating whether I should use java RMI or standard Java networking for an application i'm working on.
The app will be a networked system that has heartbeat sensors and failsafe-features. So it's a 3-tiered system, with at least a DB and java application.
So if my Database fails on one machine, I'd like the 2nd machine to "sense" this.
I'm a bit confused about Java RMI, whether it's worth it to learn it.
Or if I use standard Java networking , I can do the same as RMI? I mean, if I really know the Java networking well.
Thanks!
These days it is pretty easy to set up web services using SOAP or REST. With REST you can use XML or JSON messages without really having to know all about it. All these types of services can be accessed from .NET code or PHP or Javascript. (Well ... SOAP is sort of a pain except in .NET and Java. //personal opinion )
Spring can help you set up a service and a client interface to it is pretty easy. Fairly close to standard Annotations on bean classes and business methods define the interfaces and Spring does the heavy lifting. (I'm talking about Spring Web Services and not the Spring Remoting, though that would work as well. Spring Remoting isn't much better than RMI IMHO.)
You can also use Jersey (JAX-WS) or Jackson (Parse JSON) to do the remoting. Standard Annotations on bean classes and what-not build the interfaces. CXF will do JAX-WS and JAX-RS as well. Those are Java standards for building services and clients that communicate via remote messages.
Alternatively there are eclipse tools for generating both sides of the remote interface. All are tied to some framework (Axis-2 or CXS are some). Its sort of a code generation thing.
You might want to look into these a bit and see which one resonates with the way you look at things.
I know that I prefer all of these over using RMI. But I haven't used RMI directly in a long time.
RMI is higher level protocol compared to the bare TCP/IP support in Java via Socket class that you seem to refer to as "Java networking". If the only thing your system does is sending heartbeats and there are just few nodes you should choose RMI for simplicity reasons. As all of the participants are JVMs there is no need for any interop and extra libraries to support that and as the number of participants is limited there is no need to consider anything fancy.

Is it possible to call Java methods (or invoke objects) using .NET on cross platform?

1) I have implemented a task in Hive (Hadoop).
2) Also there is some GUI which is in .NET.
My Task is from this GUI, I want to send all parameters to Hive (Ununtu) from GUI which is in
.NET and again from Hive to GUI for processed result.
My question is that Is it possible to call Java methods (or invoke objects) using .NET?
Because I am using VM (Ubuntu) for Hive and Hadoop which is in java. I am also dealing .NET which is in Windows.
I am also new to .NET
Pls suggest me some solution to me.
For cross-platform (and cross-language) communication there are a few options:
CORBA and alternatives
Webservices (e.g. using SOAP)
Restful services
etc.
What you're using depends on your requirements (complexity, performance etc.) and what you already have available (I know neither Hadoop nor Hive that well, but I'd assume they already provide webservices or a REST interface).

Connect to BlazeDS with java stand alone app

I have a java server with a BlazeDS interface to handle Adobe AIR clients. I also have a bunch of legacy stand alone java apps that I'll need to integrate with the server. The java apps need all the same methods and remote calls that the AIR clients needs. So it would save tons of work if I could call the remote object methods from the java apps.
Anyone know if this can be done?
You can use the BlazeDS Java AMF libraries directly over HTTP. But interacting with the BlazeDS MessageBrokerServlet will require some extra work. Probably an easier path is to just expose the same Java services through another protocol that the Java code can more easily use.
Take a look on this library, it allows you to connect Java with a server running BlazeDS. On the other hand if you are interested in pure performance you can investigate another protocols..there are plenty of them.

PHP communicating with Java Server

G'day,
I have a project where I need to build a "live" java application (server) to hold state about domain objects (it's a private auction system). The java server will be communicating to and from PHP classes that hold the main back-end business functionality. The PHP classes will be stateless.
I need to communicate domain objects up to the java server (from PHP) so their state can be managed over time. Changes to the domain objects need to be saved back to the data store via calls to PHP classes on a web server.
I was thinking of wrapping my PHP classes using a XML-RPC class (e.g. Zend_Xmlrpc_Server) as they will be stateless. If/when the java application needs to write to the data store (by calling the correct PHP class method) it's a matter of using a XML-RPC client library class.
However, I'm not sure how I expose functionality in the java application so it can be reached by PHP method calls. Can anyone tell me the easiest way to do this in java ... do I just write a multi-threaded application and expose a socket? I'm after the right library classes to use to structure the java application with.
Cheers,
Paul
Expose your server-side Java code as a webservice.
There's countless ways to do this in Java but two that spring to mind are the EJB3 WS Annotations and Apache Axis.
As an aside, whichever technology you choose make sure you see it as a transport and keep the actual processing logic separate from it.
Have you already experiment the PHP Java Bridge tool ?

Best solution for using EJBs from Excel

We would like to give access to some of our EJBs from Excel. The goal is to give an API usable from VBA.
Our EJBs are mostly Stateless Session Beans that do simple CRUD operations with POJOs.
Some possible solutions:
Exposing the EJBs as WebServices and create a VB/C# dll wrapping them,
Using Corba to access the EJBs from C#,
Creating a COM Library that uses Java to access the EJBs,
Pointers to frameworks for these solution or other ideas are welcome.
You could take a look at IIOP.NET, which addresses this issue.
If you have a fairly recent ejb container, the cheapest and easiest should be to expose your beans as web services and call it from VB/C#. This doesn't require any extra tool or library.
I work on an open source project called XLLoop - this framework allows you to expose POJO functions as Excel functions.
It consists of:
An Excel add-in (XLL), which communicates over TCP to:
A Java server/library, which invokes java methods.
You could embed this java function server in an EJB and have it deployed as part of your app server.
Back in the VB6/COM/DCOM times we used the suite J-Integra to accomblish this task. I have no experience with the .NET version though.
I highly recommend IKVM. It is a java byte code to .NET assembly compiler (i.e. JAR --> DLL) and I have used it to create live JMX links and listeners in an Excel automation server. It should not be difficult for you to create a .NET assembly of your EJB client stubs and supporting libraries.
//Nicholas
You could try Obba (I work on this project):
Obba is a Java object handler for spreadsheet applications.
It provides a bridge between spreadsheets and Java classes, such that spreadsheets can be used as graphical user interface for Java libraries. Accessing your Java library form the spreadsheet requires no glue code (no VBA needed, no special Java code needed). Objects are instantiated by their original constructor. Constructors and methods are invoked using a "by name" reflection. A spreadsheet-specific factory method is not necessary. Obba provides the functions to handle objects in spreadsheets.
The Java virtual machine providing the add-in may run on the same computer or a remote computer - without any change to the spreadsheet, i.e., object referenced in the spreadsheet can reside on remote Java virtual machine.

Categories

Resources