Yii Framework Forum: Passing Value From Php To Java Application - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Passing Value From Php To Java Application Rate Topic: -----

#1 User is offline   Saqib 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 27
  • Joined: 14-November 12

Posted 09 January 2013 - 01:37 AM

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.
0

#2 User is offline   maestroQC 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 27
  • Joined: 21-September 10

Posted 09 January 2013 - 11:45 AM

Does the class that is executed with the jar command expect arguments?
0

#3 User is offline   Keith 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 1,670
  • Joined: 04-March 10
  • Location:UK

Posted 10 January 2013 - 08:58 AM

http://docs.oracle.c...mdLineArgs.html
0

#4 User is offline   Saqib 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 27
  • Joined: 14-November 12

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);
}
}
}
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users