From: <php...@li...> - 2012-07-16 13:20:54
|
hello, I'd need some help in understanding why my simple code is not working. I have a java class that computes "ls -l -a > /home/ale/output" and I want to used it from PHP. This is it: <?php ... $java = new java_class('com.myProject.HelloWorld'); $inputParametersForJava=array("-l", "-a"); $java->run("ls",$inputParametersForJava,"/home/ale/output"); ... ?> The signature of the java method I'm calling is: public static String run(String jobCommand, String[] inputParameters, String outputFile) {...} If I add a "main" method in the class and call "run" from there (with the same parameters as above), everything works (i.e. I get the output of "ls -l -a" in the file "/home/ale/output"). But when I use php/java bridge, I get no error in PHP and no output file is created. I know that: - $java = new java_class('com.myProject.HelloWorld'); works because I do not have an "error 500". - $inputParametersForJava=array("-l", "-a"); works because it's a simple arry declaration. - The problem is in the calling of "run", but where? and why? Thanks all for your help AC |
From: <php...@li...> - 2012-07-16 19:58:14
|
Declare the procedure to throw an error and you'll see it, including the stack trace. Please see FAQ for details. Most likely a permission denied. |
From: <php...@li...> - 2012-07-17 09:25:32
|
which kind of permissions should I set to be able to use the class? or do you mean permission for browsing the folder with "ls"? thanks AC --- Lun 16/7/12, php...@li... <php...@li...> ha scritto: > Da: php...@li... <php...@li...> > Oggetto: Re: [Php-java-bridge-users] beginner's info > A: php...@li... > Data: Lunedì 16 luglio 2012, 19:58 > Declare the procedure to throw an > error and you'll see it, including the > stack trace. Please see FAQ for details. > > Most likely a permission denied. > ------------------------------------------------------------------------------ > Live Security Virtual Conference > Exclusive live event will cover all the ways today's > security and > threat landscape has changed and how IT managers can > respond. Discussions > will include endpoint security, mobile security and the > latest in malware > threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ > _______________________________________________ > php-java-bridge-users mailing list > php...@li... > https://lists.sourceforge.net/lists/listinfo/php-java-bridge-users > |
From: <php...@li...> - 2012-07-17 17:36:47
|
Hi, I'm using this in my PHP file: $javaClass = new java_class("my.project.MyClass"); Then I delete the MyClass.class file, and the program still runs. How is this possible? Are class files stored somewhere? Thanks AC |
From: <php...@li...> - 2012-07-18 08:11:55
|
[PHP code] $java = new java_class("my.project.Experiment"); $myResult = $java->run(); echo $myResult; [JAVA code] package my.project; public class Experiment { public static String run(String x){ return "results: " +x; } } Until here everything works fine. Then I create another class, Experiment2, exactly as the first one but the method is now called run2. I delete the Experiment class (NB: if I run "find -name Experiment.class" nothing is found). I then change the PHP code to use Experiment2, and I get an "error 500". This is already a problem since the class is there and is very basic. But then, if I change the PHP code and try to use the Experiment class, it works again! That sounds as impossible to me because Experiment2.class is for some reason not found, and also because Experiment.class is nowhere to be found in the system. The only solution I could find is that PHP is storing the information on the java classes somewhere, but I couldn't find where. I also tried to delete Firefox's history, but the results are the same. Any help would be highly appreciated. Thanks in advance, AC |
From: <php...@li...> - 2012-07-18 08:23:32
|
AC, your java server (tomcat, etc.) is a permanent process, where as your php scripts are evaluated on every request. If you want to see changes to your java code, you'll have to restart (redeploy) the service that holds your java classes (tomcat, pjb-standalone) because these processes hold the bytecode contained in your .class files in memory and thus won't notice/care that the file went away. On Wed, Jul 18, 2012 at 10:11 AM, < php...@li...> wrote: > [PHP code] > $java = new java_class("my.project.Experiment"); > $myResult = $java->run(); > echo $myResult; > > [JAVA code] > package my.project; > > public class Experiment { > public static String run(String x){ > return "results: " +x; > } > } > > Until here everything works fine. > > Then I create another class, Experiment2, exactly as the first one but the > method is now called run2. > > I delete the Experiment class (NB: if I run "find -name Experiment.class" > nothing is found). > > I then change the PHP code to use Experiment2, and I get an "error 500". > This is already a problem since the class is there and is very basic. > But then, if I change the PHP code and try to use the Experiment class, it > works again! > > That sounds as impossible to me because Experiment2.class is for some > reason not found, and also because Experiment.class is nowhere to be found > in the system. > > The only solution I could find is that PHP is storing the information on > the java classes somewhere, but I couldn't find where. > I also tried to delete Firefox's history, but the results are the same. > > Any help would be highly appreciated. > Thanks in advance, > AC > > > > > ------------------------------------------------------------------------------ > Live Security Virtual Conference > Exclusive live event will cover all the ways today's security and > threat landscape has changed and how IT managers can respond. Discussions > will include endpoint security, mobile security and the latest in malware > threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ > _______________________________________________ > php-java-bridge-users mailing list > php...@li... > https://lists.sourceforge.net/lists/listinfo/php-java-bridge-users > -- Dominik Dorn http://dominikdorn.com http://twitter.com/domdorn Skripten, Mitschriften, Lernunterlagen, etc. findest Du auf http://www.studyguru.eu ! |