Executing jar inside php step by step explained

Java Program:

package in.javadomain;

public class Hello {

	public static void main(String[] args) {
		Hello h = new Hello();
		System.out.println(h.helloName("Javadomain.in"));
	}

	private static String helloName(String name){
		return "Hello "+name;
	}

}

Output:

Hello Javadomain.in

 

Now Create the Jar like below using Eclipse,
Rightclick on the project in eclipse -> Export -> Runnable JAR file -> Choose the Project and Export location.
runnable jar - hello

Note: Do not forgot to choose the package required libraries into generated JAR under library handling.

Now Run the Above Created Jar in PHP:

<!--?php echo exec("java -jar hello.jar "); ?-->

Output:

Hello Javadomain.in

 

Recommended Java Books:

Recommended PHP Books:

247 total views, 1 views today

Leave a Reply

Your email address will not be published. Required fields are marked *