如何使用PHP从Web服务器运行jar [英] How to run a jar from a web server using PHP

查看:125
本文介绍了如何使用PHP从Web服务器运行jar的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个.jar文件打印在连接到该PC的打印机上,当我执行jar文件时,它打印得非常好,所以我将该文件放在Apache服务器上,但是当我尝试使用PHP运行它时,它不起作用,我只是得到一个空白页面,没有任何打印。

I have a .jar file that prints on the printer connected to that PC, when I execute the jar file, it prints perfectly fine, so I placed that file on the Apache server, but when I try to run it using PHP, it doesn't work, I just get a blank page and with nothing printed.

这是我的工作,通过使用PHP从命令行运行Jar:

This is what I do, by running the Jar from the command line using PHP:

<?php exec("java -jar Print.jar"); ?>

我尝试了一切,并使用完整路径和所有内容,但仍然无效。有没有办法通过从它访问PHP页面在Web服务器PC上打印东西?或者使用任何其他技术,如果在PHP中不可能。基本上我在服务器上也有一个PDF文件,并且正在服务器打印机上打印。

I tried everything, and using the full path and everything, but still doesn't work. Is there a way to print something on a web server PC by accessing a PHP page from it? Or using any other technology if it's not possible in PHP. Basically I have a PDF file also on the server, and that is being printed on the server printer.

我想问题是Apache或PHP都没有足够的权限自己运行它。有没有办法给它许可?

I guess the problem is that either Apache or PHP doesn't have enough permission to run it by itself. Is there a way to give it permission?

我的想法是我想要在服务器打印机上打印Web服务器上的PDF文件。

My idea is I want a PDF file on a web server to be printed on the server printer.

推荐答案

基于这个链接,你的代码很好。
你必须检查环境变量和权限:apache无权执行。要么java-jar在目录中启动运行,那么无法通过java找到打印机找不到的pdf文件。

Based on this link, your code is good. You have to check the environment variables and permissions: either apache has no right to execute., either the java-jar starts an runs in a directory, where has no access to your pdf file either printer not found, by java.

这篇关于如何使用PHP从Web服务器运行jar的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆