how to use java code from .net desktop application? - java

I want to Use Some Java Code From the WCF Service. Basically I need to intreact with the java application from the .net so how can I make it out for that? Any guidance for that?
I was just wondering that how can i call java code from my .net desktop application? Do I need to create .exe file of my java poject or jar? How would I invoke that java project from my .net desktop application?
Like some code in .net desktopp application will call
void startprocessing ();
code written in java application
Let me Clear the Things What i want to implement..
I have one desktop appplication of windows and I want to integrate my speech recgnition facility in that application which is in java. What I want is to exchange the audio data as binary and some strings from .net application to my java application so I can process on that binary data to convert wav file and etc and recginze it..that is just completed ..but what I need to know is how to send those strings and some binary data to java application and just invoke that java application ?? Do I need to 'use'(?) wcf or other service ?

Going out on a limb here, sounds like you java app needs to expose the method you want to call via a web-service. That's of course assuming you have control over that in terms of the java app you're interacting with. Not sure though you can access that method simply by compiling your java app to native.

You can take a look at JNBridge, which provides interop possibilities between Java and .NET. However, as another poster has suggested, exposing the functionality through a web service is probably a better solution.
A quick Google search will give you plenty of information on how to create web services in Java, but for starters you can take a look at: http://docs.oracle.com/javaee/6/tutorial/doc/bnayl.html

I have Successfully done that with the axis 2 webservice with tomcat apache server with the following link..its too easy .i really got succeeded
http://blog.sencide.com/2011/06/create-web-service-using-apache-axis2.html

Related

Using Java Program as part of Java Web APP

I have built a java program that does very simple reading, storing, and processing of server side data that it receives from some electronic sensors. This information now needs to be put onto a webpage.
Some calculations need to be done server side so I want to keep the Processing done in java rather than an interpretative language like javascript or python.
Anyway How do I get the information from the java program up onto a website using a java web application? I am a little unfamiliar with JSP and Servlets though they aren't too complicated I do not know how to get my current working program to work with those and print out the server side information.
It doesn't need to be anything fancy this is just a simple program to do some real time remote monitoring over the web of some electronics.
I do know and understand HTML as well so i do know how to work with those.
You can use tomcat+spring, here is link to a tutorial that teaches you how to create a RESTful webservice https://spring.io/guides/gs/rest-service/
What you'll need to do is basically mapping the http requests to some functions that will call your functions in your original program.

How integrate RapidMiner in a PHP web application?

I've got an implementation in RapidMiner that classifies questions according to Bloom's taxonomy. I need to consume the data produced by a web application developed in PHP and show the results in the interface of the web application.
So I'm wondering if it is possible that the application in PHP communicates with RapidMiner to process the data and show the results provided by RapidMiner in the interface.
I know RapidMiner is implemented in Java, and there is the option of using Java bridge to comunicate PHP and JAVA, but I'm not sure if that is a solution to this.
Why not try to communicate with xml, for example, PHP app sends a list of questions via xml to rm, it then processes it and returns an xml feed. I think this'll likely be the easiest solution.. As far as performance, I can't say one way or the other if it's the best solution

is it possible to have a hybrid PHP+Java web application on Google App Engine?

I want to create an application that submits same/similar data to sites containing web forms. These sites use PHP scripts...
I have a php script with me, that submits data in the manner that i require, to such forms. What I want to do is, design an entire web app around this code... I tried to obtain equivalent java code that does what the php code is doing, but could not obtain such code...
Since Google App Engine supports Quercus framework for PHP, what I am thinking now is, use the PHP code for actual submission of forms to their actions, and rest of application (that tracks all submissions and does other stuff like login/logout...) is in Java.
This would require some method by which I can pass the relevant form parameters from Java code to the PHP script, then some way for the php script to return the response of each submission back to the java code.
Is such an application doable? Pls keep in mind that I want to use Google App Engine for this purpose.
Nowadays it is possible to use different languages in different modules of the same app.
See Using both Java and Python with the new "Module" feature on AppEngine?
It should be doable with Quercus. We deploy a Python app that has some Java/Clojure backend processors but both languages are "native" to GAE. Using PHP will be a serious pain and not worth it all. I suggest that you just learn Python you will master it faster than using Quercus on GAE.
If you also go after PHP you stick to your LAMP knowledge. I suggest thay you do now!
Disclaimer: I wanted to use JRuby on AppEngine but I had a lot of difficulties (plus you have to know how everything works optimally on GAE) so I took up Python

Java application with JNI

I am new to java and want to develop a java application which will run continuously like a server.
Is it possible in Java to develop a UI less application which will work continuously? This application should also have JNI support, so functions exported using JNI should get called from a C++ application.
Can anybody tell me the pointers to start?
Help is appreciated, thanks.
Vishal N
It is certainly possible to run without a UI. By the sounds of it you would like to create your Java APP as a console app and then run it as a Windows Service/Linux Daemon (You did not mention the OS). There are java service wrappers out there that lets you run your java code as a service (e.g. this one) or you could write your own.
I recommend this book to learn the JNI. Although it sounds like what you need it not really JNI but rather an interface exposed over TCP or something similar that another C++ app can use to talk to your app. JNI won't allow another process to talk to your app, it is there to extend your Java code with functionality that cannot be implemented in Java itself e.g. calling some Windows API function.
Edit:
By the way, a plain Java Hello World App like this one IS a console app:
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, World");
}
}
Yes you can develop UI less applications in Java.
I'll expect an application server to handle multiple requests, transactions, security, life-cycle, persistence, etc.
If answer is Yes then I will choose the Java EE route to implement your requirements. I'll implement my business model using EJB3.0 and deploy in one of the application servers i.e. Glassfish, JBoss etc. which will support all features described above without reinventing the wheel.
Note: The solution will also give flexibility to expose your remote methods using WebService, CORBA or JMS.
If answer is No then I might create my own standalone server type application which will listen on some port and communicate through some bespoke protocol.
In order to support JNI -I would expect that you'd have to write a plain JavaBean wrapper or proxy. This proxy would then be used by the JNI.
Yes.
Is it possible in Java to develop a UI less application which will work continuously?
Create a thread or code main thread that will run foreever.
This application should also have JNI support, so functions exported using JNI should get called from a C++ application.
yes , have a look at here
You can certainly develop a Java application without a user interface; I think most folks would agree that it's easier than developing one with a user interface.
Regarding JNI, if I understand the question, you've got it backwards; using C++ as an example, JNI lets you call C++ code from Java, not Java code from C++.
Yes, you can run Java as service (daemon). You can simply run your code a "daemonize" it. This way, it will be detached from terminal sessions and will run in background.
Take a look here:
https://github.com/mkowsiak/jnicookbook/tree/master/recipes/recipeNo022
to see how you can run service inside C.
And here, to check out how to run service part in Java:
https://github.com/mkowsiak/jnicookbook/tree/master/recipes/recipeNo029
Have fun with JNI!

How should I architect JasperReports with a PHP front+backend system

Our system is written completely in PHP.
For various business reasons (which are a given) I need to build the reports of the system using JasperReports.
What architecture should I use? Should I put the Jasper as a stand alone server (if possible) and let the php query against it, should I have it generate the reports with a cron, and then let the PHP scoop up the files and send them to the web client/browser...
JasperServer seems to be the best option, having:
Comprehensive Web Services, Java, and HTTP APIs, as well as support for Web Services from non-Java environments such as .NET (C#), C++, and PHP
Another option is to implement something like that yourself, with only the functionality you need. Make a separate java web-app that generates the reports, using either web-services or REST to communicate with it.
If you like to keep things simple and "free", then i recommend:
Build your own small Java webapp.
Use DynamicJasper to build customized reports.
Expose a web service from the Java app, and call it from your PHP.
Java app will reply with a PDF file.
You can use the php java extension and compile and generate the report right from php. Example code and instructions: here.

Categories