-2

How can I pass parameter to java class in PHP

<?php
$output = shell_exec('java xbee');  
print_r($output); ?>/*

above one is work fine with my java, now in my scenario, I have to pass the parameter to java class. Can anyone help me with this?

Jibin Balachandran
  • 3,381
  • 1
  • 24
  • 38

1 Answers1

3

You can access arguments in java within your main method

$output = shell_exec('java xbee hello'); 

The hello argument would now be in args[0]

public static void main(String[] args){
    System.out.println(args[0]);
}

That should print hello.

MarcHoH
  • 340
  • 1
  • 6