Java命令类路径和PHP在Linux中 [英] Java command classpath and PHP in Linux
问题描述
您好,我有一个Java jar文件和一个批处理文件,我想用-cp命令和PHP java的运行。
Hello I have a java jar files and a batch file that I want to run using the java -cp command and from PHP.
我的jar文件是一个叫我的服务器罐子的文件夹内,我做如下运行它们:
My jar files are inside a folder called "jars" in my server and I'm doing as following to run them :
//java.php
$result = exec('java -cp "pack1.jar:pack2.jar" pack3.connect.CommandLine -rb batchfile.odlbat');
echo $result;
这个命令在PHP中工作时,我所有的瓶子和批处理文件是在同一文件夹作为我javacall.php文件。
This command is working in PHP when all my jar and batch file are in the same folder as my javacall.php file.
现在我想我的罐子和批处理文件复制到一个新的文件夹父所以我试图修改脚本,从父文件夹中加载的jar和批处理文件,但我得到这个错误:
Now I want to copy my jar and batch files to a new folder "parent" so I tried to modify the script to load the jar and batch files from the "parent" folder but I get this error :
//java.php
$result = exec('java -cp "parent/pack1.jar:parent/pack2.jar" parent/pack3.connect.CommandLine -rb parent/batchfile.odlbat');
echo $result;
错误:无法找到或加载主类parent.pack3.connect.CommandLine
Error : Could not find or load main class parent.pack3.connect.CommandLine
任何帮助吗?
感谢
推荐答案
如果您检查类路径的文件:的 http://docs.oracle.com/javase/7/docs/technotes/tools/windows/classpath.html
If you check the documentation for the classpath: http://docs.oracle.com/javase/7/docs/technotes/tools/windows/classpath.html
我认为你必须使用来代替:
I think that you must use instead:
java -cp "./parent" parent/pack3.connect.CommandLine -rb parent/batchfile.odlbat
这篇关于Java命令类路径和PHP在Linux中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!