echo "<pre>The output was:\n".$output_str."\n\n";
echo "The return value was ".$return_var."</pre>";
and my java file is:
public class try2{
public static void main(String [] args)
{
System.out.println("hello");
}
}
Then hello is printed in the PHP file, that works fine. but if my java file is a bit more complicated, like this file i downloaded, which uses javax.bluetooth, to detect bluetooth devices, no output is shown...
public void serviceSearchCompleted(int transID, int respCode) {
}
public void servicesDiscovered(int transID, ServiceRecord[] servRecord) {
}
};
synchronized(inquiryCompletedEvent) {
boolean started = LocalDevice.getLocalDevice().getDiscoveryAgent().startInquiry(DiscoveryAgent.G IAC, listener);
if (started) {
System.out.println("wait for device inquiry to complete...");
inquiryCompletedEvent.wait();
System.out.println(devicesDiscovered.size() + " device(s) found");
}
}
}
}
I was asked if it compiling and running RemoteDeviceDiscovery on cmd line worked, i tried it out, and noo it didnt!
javac RemoteDeviceDiscovery.java
and i get all these errors
RemoteDeviceDiscovery.java:3: package javax.bluetooth does not exist
import javax.bluetooth.*;
^
RemoteDeviceDiscovery.java:19: cannot find symbol
symbol : class DiscoveryListener
location: class RemoteDeviceDiscovery
DiscoveryListener listener = new DiscoveryListener() {
^
RemoteDeviceDiscovery.java:19: cannot find symbol
symbol : class DiscoveryListener
location: class RemoteDeviceDiscovery
DiscoveryListener listener = new DiscoveryListener() {
^
RemoteDeviceDiscovery.java:45: cannot find symbol
symbol : variable DiscoveryAgent
location: class RemoteDeviceDiscovery
boolean started = LocalDevice.getLocalDevice().getDiscoveryAgent().s
tartInquiry(DiscoveryAgent.GIAC, listener);
^
RemoteDeviceDiscovery.java:45: cannot find symbol
symbol : variable LocalDevice
location: class RemoteDeviceDiscovery
boolean started = LocalDevice.getLocalDevice().getDiscoveryAgent().s
tartInquiry(DiscoveryAgent.GIAC, listener);
^
5 errors
It appears like it can't find the bluecove.jar, although i added it to the classpath and the path in the system variables...
This isn't a php issue.
This is java code that you have not been able to compile. Once you're able to get the code compiled and working, then you can worry about using php to execute it the program.
Bookmarks