php, java code direct integration - java

I need a way to directly integrate a php code with a java one. I know there is a software bridge to achieve that, but I need to know whether there exist a more direct link, via commands only. I meant to integrate java code into php code.

Related

Implementing a Java Application in Ruby

Is it possible to implement a program written in Java on a website coded using Ruby? Currently developing a website where data from a form must be taken in, parsed, and used to fill out objects in the application. Currently a Java Programmer which is why using Java to develop the application would be much easier. However, Ruby is similar enough that it will work if need be.
I know that there are applications such as JRuby that allow Ruby to be used in Java. Is the reverse true, and if so, how does it work?
JRuby allows you to call Java from Ruby as well: https://github.com/jruby/jruby/wiki/CallingJavaFromJRuby
Before going this route, if you prefer to write your web application in Java (you mentioned that you are more comfortable with Java), why not use Spring Boot? Spring Boot lets you develop with minimal setup like Ruby on Rails.
You can go the jRuby way and mix Ruby and Java and yes it wors in both directions.
See this wiki for examples and how to.
CallingJavaFromJRuby
In theory you can call a java Jar and catch the results in Ruby but for a website I advise against it.
You could present the Java functionality as a webservice but you could program the whole thing in Java or Ruby also.

how to use java code from .net desktop application?

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

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 applet in a Delphi form

Is there any way, without using TWebBrowser, to load a java applet in a Delphi form and interact with it?
Theres a page which contains a applet that I want to show inside my Delphi app (in a particular form) and after the user close it (or do any other operation) I want to interact with it (getting some details about what user did).
I know that TWebBrowser is capable of loading a java applet, but it will not let me interact and get what I need.
Similar thing can be done with a .Net assembly, but I have not seen anything like it using a java applet.
Edit:
As #PA pointed out:
"it will not let me interact" ... well, that's the actual reason for browsers running java applets inside a sandbox
Well .. that was not what a meant. I meant I am not able to get a value from a edit (for example) as I am able to do with other languages. I know that java runs inside a VM, but .Net runs as well and i am able to interact with .Net using some COM and stuff like that.
I think the only way to use Java Applets in Delphi programs wihtout TWebBrowser is to use ActiveX technology. May be this link from google can help you: http://www.oracle.com/technetwork/java/index-jsp-141438.html
May be you should take a look at Java Native Interface (JNI) technology. For example, you can find its Delphi implementation here.

Php/Java Integration

Have you experience of integration of php and Java? I've written a class in Java "Hello". Now I want to call its method from php when I create an instance of this class from php with
$obj = new Java(Hello);
Then it gives me fatal error. I've tried many times to setup php ini variables etc but I couldn't find anything. Please advice me how can I set it up.
Thanks in advance
Reference: http://php.net/manual/en/book.java.php
Have a look at:
PHP-Java Bridge
The PHP/Java Bridge is an
implementation of a streaming,
XML-based network protocol, which can
be used to connect a native script
engine, for example PHP, Scheme or
Python, with a Java virtual machine.
It is up to 50 times faster than local
RPC via SOAP, requires less resources
on the web-server side. It is faster
and more reliable than direct
communication via the Java Native
Interface, and it requires no
additional components to invoke Java
procedures from PHP or PHP procedures
from Java.
Could it be you are just missing the quotes around the Java Class? Also make sure you actually do have a Java VM on the machine you are trying to run the code on and make sure you have properly set up the config options. Also, the Java extension is a PECL extension and has to be installed. It is not part of the native distribution. Furthermore, the extension is considered unmaintained and dead, so you might want to have a look at the JavaBridge suggested elsewhere. Zend Server also brings a JavaBridge.
Check out this article: http://www.devshed.com/c/a/PHP/Using-PHP-with-Java/
They say it's possible (and how to do it). I've never done it, so I can't vouch for it...
In my experience the best way to interact between Java and PHP is through a WebService layer. NuSoap for PHP is very good, and you can consume the webservice in Java to create a stub that will build the request/response object.
There are many ways few are:
PHP Java Bridge
Java Integration in PHP
Using web services to pass data in between like SOAP
Using simple HTTP data passage between Java and PHP see (facejar uses the same technique)
Client site script (AJAX)
If you are after security, use option 1 otherwise I prefer using option 4 which is a bit faster when it comes to performance.

Categories