Reputation: 14645
Is there are tools for converting java code to php? I have source code of java library and I need it to convert to php.
Upvotes: 13
Views: 36741
Reputation: 119
It is possible to automatically convert it. This is called a source to source compiler. Normally when you compile software, the parser will build an abstract syntax tree and convert this into the target machine language code. But it is just as possible to have a compiler convert this into another high level (compilable) language.
Java is a strongly typed language, and PHP is not, so source to source compilers are rare and the code conversion process is incomplete. However this said, there is a reasonably good one with a free demo at: http://javatophp.com
Upvotes: 11
Reputation: 310884
There are lots of aspects of Java that cannot be expressed in PHP. Type safety for one. This sounds like a fool's errand to me. If you were looking to go in the opposite direction the question might have some interest.
Upvotes: 0
Reputation: 1184
I don't think there is a solution like this currently.
You might try using a php-java bridge that would allow you to call the java code from within PHP: http://php-java-bridge.sourceforge.net/pjb/
Zend Server also provides a bridge
Upvotes: 3
Reputation: 9056
Team of 5 folks at Facebook have spent 18 month to write sofrware that converts PHP to C++ (meet: HipHop). There is no such software for transforming from Java to PHP yet.
The answer is: yes... it is possible if you have year and a half and team of pro programmers :) Otherwise, you rewrite it manually (I think, this is your choise).
Upvotes: 2
Reputation: 968
Automatically - No. Now. Maybe in future. Don't spend time, write new code bro.
Upvotes: 5