how to call a java method from php

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • swamyvnvs
    New Member
    • Mar 2010
    • 3

    how to call a java method from php

    HI friends,

    i have a problem when i call a java method from php code, i saw php.net site ifollow all thr steps , but i got the classNotFoundEx ceptions.

    my code is like this


    JavaClass

    Code:
    public class SampleStatic
    {    
    	public static void main(String args[])
    	{
    		System.out.println("saibaba");	
    
    	}
    	public void sample(int arg)
    	{
    		System.out.println("hai"+arg);
    	}
    }
    PhpCode
    Code:
    <?php
    require_once("Java.inc");
    $sample = new Java("SampleStatic");
    $sample->sample(10);
    ?>
    I am using vm php bridge jar file.

    if any one know please tell me.

    Thanks and Regards

    swamy
  • philipwayne
    New Member
    • Mar 2010
    • 50

    #2
    Umm I don't think you can include Java code like you do regular PHP code. Meaning that your require_once( "Java.inc" ); shouldn't contain Java it should contain PHP you'd need to look into the Java extension and find the correct way of including files.

    Comment

    • swamyvnvs
      New Member
      • Mar 2010
      • 3

      #3
      Hi,

      This Java.inc contasins php code only this file was given by the vm bridge driver.If we donot include java.inc i got another error . if I include java.ince run the predefine java class it will work.But if we run the our custom classes we got the classNotFoundEx ception.
      So if any know ,please tell to me


      Thanks and Regards

      swamy vnvs

      Comment

      Working...