Reputation: 8246
I'm attempting to run a small Java class from within a PHP script. It works as expected on Linux, but when the same script is executed on Windows I receive:
Could not find or load main class JDBCProxy
Here's the relevant PHP:
$classpath = join(PATH_SEPARATOR, array(
dirname(__FILE__).DIRECTORY_SEPARATOR.'JDBCProxy',
dirname(__FILE__).DIRECTORY_SEPARATOR.'JDBCProxy'.DIRECTORY_SEPARATOR.'libs'.DIRECTORY_SEPARATOR.'json-simple-1.1.1.jar',
));
$cmd = sprintf("java -cp '%s' JDBCProxy", $classpath);
...
$process = proc_open($cmd, $descriptorspec, $pipes);
The output of sprintf
is
java -cp 'C:\worker\lib\DB\JDBCProxy;C:\worker\lib\DB\JDBCProxy\libs\json-simple-1.1.1.jar' JDBCProxy
When run directly from the command line, this works as expected. Why isn't Java able to locate the class when run from the context of PHP?
Upvotes: 1
Views: 36
Reputation: 4564
For Windows, use double quotes ("
) instead of single ones ('
).
See Including all the jars in a directory within the Java classpath for Java specifics and this answer for Windows' treatment of single quotes.
Upvotes: 1