您好我想用java rmi编写客户端/服务器应用程序,客户端能够在服务器端运行窗口媒体播放器。我使用过这样的ProcessBuilder
类:
ProcessBuilder process= new ProcessBuilder(“mwplayer”).start();
但它不起作用。它导致了这些例外:
java.io.IOException: Cannot run program "mwplayer": CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessBuilder.start(Unknown Source)
at server.ServerFrame.mediaPlayer(ServerFrame.java:135)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at sun.rmi.server.UnicastServerRef.dispatch(Unknown Source)
at sun.rmi.transport.Transport$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.<init>(Unknown Source)
at java.lang.ProcessImpl.start(Unknown Source)
... 16 more
我该如何解决这个问题?你能帮帮我吗? 非常感谢
答案 0 :(得分:1)
错误消息告诉您ProcessBuilder
无法看到名为mwplayer
的文件。
答案 1 :(得分:1)
也许尝试指定mwplayer的完整路径,而不仅仅是二进制名称。我想在你的通话环境中没有设置任何环境变量。
答案 2 :(得分:1)
不是它被称为'wmplayer',m和w交换了吗?