I'm trying to make communication between PHP and Java.
Here's what I want to do. PHP pass a parameter ID to a Java file.
The Java get the ID and run some script and return a, ARRAY to the PHP.
I have read out a lot such as PHP/Java Bridge, SOAP, RestCall ...
But I couldn't found out one which works. basically is I don't know how to configure.
I want to find some simple examples which I can understand. And I don't need to use PHP/Java Bridge.
Something easier would do.
Update.
*I had tried Curl call to the Java file, on the $result = curl_exec($curl) returns the entire CODE in the Java.*
I even try Java Servlet, it also return only the entire CODE in the Java.
What I want is PHP make a GET request to the Java, Java will detect the GET request and obtain a parameter ID. Run some process and return an ARRAY back to the PHP.
I want it to be done in a HTTP request only.
But I couldn't figure out how it works. I even tried the HTTPComponent.
Please help out and show me simple example in the PHP and Java file.
I even follow this servlet http://brajeshwar.com/2008/handling-http-get-requests-in-java-servlets/ CGI http://www.javaworld.com/jw-01-1997/jw-01-cgiscripts.html?page=3 , and not only these. A lot examples. But none work.
Did I miss out anything? I will provide more details. I used XAMPP, every project and file will be in my htdocs.
All request will be something like this "http: // localhost/test/...."
Thank you.
Sorry that I didn't stated clearly enough.
The JAVA file is the normal JAVA file such as
public class HelloWorld {
String hw = "Hello World";
public void getHelloWorld() {
System.out.println("abc");
}
public static void main(String [] args){
System.out.println("abc");
}
}
Thank you.
Update 2
Here's my next question.
Like those Curl, Rest, Cgi call.. Its actually called to the .Java file right? And the result return is the Entire source code of the .Java.
This is because there's no compiler to compile the Java class right? I put the Java file in the xampp/htdocs, I compile it using Netbeans.
So when I call from PHP, there's no one to compile it? Correct me if I'm wrong?
So I should put the .Java file in a server such as Tomcat right? Or ways to compile it? I tried to put in the tomcat webapps, and connect to it through localhost:8080/test/test.java
It return me error 404.
How to access to .Java fil using Web Browser? Please help me.
Thank you.
SOLVED
Works Java with RESTFul. And I can get Curl call to Java.
Follow this guide
Very clear for beginners in Java like me.