Hello everyone,
I am bothering again with a weird question again. Earlier I tried to verify digital signature of pdf/doc file. As I saw, it is wise to do it with java application, i made a jar file for this purpose. Now what i need to do, call the jar file with a input (path of the file) and get the output. I could not take input but I could get output. The code is like:
$ac = Yii::app()->basePath;
exec('java -jar '.$ac.'\\..\\jar\\VerifyPdf6.jar', $output);
echo "<pre>";
print_r($output);
echo "<pre>";
echo "</br>";
Now,this works and I get the output from $output. Now I want to take an input and pass the value in the jar 'VerifyPdf.jar'. that value will be used in the file parameter. Now, many people suggested to pass a value along with execution (exec) and get the value in java using request.getParameter(). But, in java application, the function was not recognized and i think it is mainly used in java servlet and jsp but I am not so sure. Can anyone help me with this ?
The code I am working to test now is :
$arg1 = "This is test from the php";
exec('java -jar Testphp2java.jar arg1', $output);
echo "<pre>";
print_r($output);
echo "</pre>";
here, I want to take the $arg1 and print it from java ($output)......
Thank you very much for reading this. Any feedback will be big help for this newbie.
Page 1 of 1
Passing Value From Php To Java Application
#2
Posted 09 January 2013 - 11:45 AM
Does the class that is executed with the jar command expect arguments?
#4
Posted 14 January 2013 - 02:45 AM
I got the answer:
PHP PAGE:
<?php
$some_value = 'D:\NetBeansProjects\Testphp2java\dist';
//exec('java -jar Testphp2java.jar this_is_the_valye', $output);
exec("java -jar Testphp2java.jar $some_value", $output);
echo "<pre>";
print_r($output);
echo "</pre>";
?>
JAVA APPLICATION:
/**@author Saqib */
public class Testphp2java
{
public String a = "Testing from string a";
public Testphp2java() throws Exception
{
System.out.println("Hello, This is testing...1,2,3...Done");
System.out.println("String a: " + a);
}
public static void main(String[] args)
{
try
{
String abc = args[0];
System.out.println(args[0]);
System.out.println(abc);
new Testphp2java();
}
catch(Exception e)
{
System.out.println(e);
}
}
}
PHP PAGE:
<?php
$some_value = 'D:\NetBeansProjects\Testphp2java\dist';
//exec('java -jar Testphp2java.jar this_is_the_valye', $output);
exec("java -jar Testphp2java.jar $some_value", $output);
echo "<pre>";
print_r($output);
echo "</pre>";
?>
JAVA APPLICATION:
/**@author Saqib */
public class Testphp2java
{
public String a = "Testing from string a";
public Testphp2java() throws Exception
{
System.out.println("Hello, This is testing...1,2,3...Done");
System.out.println("String a: " + a);
}
public static void main(String[] args)
{
try
{
String abc = args[0];
System.out.println(args[0]);
System.out.println(abc);
new Testphp2java();
}
catch(Exception e)
{
System.out.println(e);
}
}
}
Share this topic:
Page 1 of 1

Help











