php_java extension does not work

Asked

Viewed 57 times

1

Hello!

I am having problems calling a java application in my php code, through the extension php_java:

1) I changed the configuration in php.ini, and the files are in the address described in the list below: descrição do php_java no phpinfo()

And below the php code, which calls a class I made for testing, because I will need the extension running to use a class of a bank that works with billet generation.

<?php
    $javaPHP = new Java('TesteJP');
    $javaPHP->set("TEST");
    echo "Java Method = " . $javaPHP->get();
?>

But when accessing in the browser, it returns a message as a restarted connection, or and ERR_CONNECTION_RESET in the footer. And when accessing the event viewer on the server, I find this error:

Faulting application Apache.exe version 2.0.58.200, faulting module
unknown, version 0.0.0.0, fault address 0x01495b58.

The copy of the error screen is just below:

Cópia da tela do erro.

However, in some moments when I try to access, the page loads, but returning an error message:

Fatal error: java() [<a href='function.java'>function.java</a>]: Unable to
 create Java Virtual Machine in H:\Desenvolvimento\sites\abra3\bol.php on 
line 181
  • 1

    could simply use shell functions.. exec(), passthru(),, among others

  • @Danielomine, you wouldn’t have security problems leaving the class exposed?

  • what would be "leave the class exposed"?

  • @Danielomine accessible in the server folder. Configuring by the php_java extension, the classes are in a folder that apache does not see, only php.

  • via CLI also ... can run by exec() from a location that "apache doesn’t see".. Alias, the fact that apache access the java file implies what in security? The important thing is that the java file is not in the public folder.

  • If it’s the same as calling for the CLI, okay... But still, my question is this: using exec() I don’t know how to return the information, which I would get through the java extension.

  • the second parameter of exec() returns the output. The third parameter returns the status.. http://php.net/exec

  • Example: exec('java arquivo.jar', $output);. The first parameter is the command. You can write a command as if it were in a console.

  • @Danielomine understood. This would suit me perfectly if the class I was going to use in production had been made by me. It is the class of a bank to take care of the generation of billets

  • , que chama uma classe que fiz para teste, pois precisarei da extensão funcionando para utilizar uma classe de um banco que trabalha com geração de boleto. In this excerpt I understood that you would make a java class to connect with the java class of the boleto or the database api...

  • In fact, you can still create a java script to do such a communication and then in php invoke by exec as an example.. but if you want to continue in the way presented in the question, it seems that the class is missing. Something like java_require().

Show 6 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.