Hey there,

I'm new to this exec() function, but i was told i can use it to run a java file.

For example, if my php file is:

exec("java.exe try2", $output, $return_var);
$output_str = join($output, "\n");

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...

import java.io.IOException;
import java.util.Vector;
import javax.bluetooth.*;

/**
* Minimal Device Discovery example.
*/
public class RemoteDeviceDiscovery {

public static final Vector/*<RemoteDevice>*/ devicesDiscovered = new Vector();

public static void main(String[] args) throws IOException, InterruptedException {

final Object inquiryCompletedEvent = new Object();

devicesDiscovered.clear();

DiscoveryListener listener = new DiscoveryListener() {

public void deviceDiscovered(RemoteDevice btDevice, DeviceClass cod) {
System.out.println("Device " + btDevice.getBluetoothAddress() + " found");
devicesDiscovered.addElement(btDevice);
try {
System.out.println(" name " + btDevice.getFriendlyName(false));
} catch (IOException cantGetDeviceName) {
}
}

public void inquiryCompleted(int discType) {
System.out.println("Device Inquiry completed!");
synchronized(inquiryCompletedEvent){
inquiryCompletedEvent.notifyAll();
}
}

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...

What should i do??

Thanks alot!