PHPackages                             php-java/php-java - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. php-java/php-java

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

php-java/php-java
=================

Implement JVM by PHP

44655636[1 issues](https://github.com/php-java/php-java/issues)PHP

Since Dec 25Pushed 2y ago11 watchersCompare

[ Source](https://github.com/php-java/php-java)[ Packagist](https://packagist.org/packages/php-java/php-java)[ RSS](/packages/php-java-php-java/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

PHPJava - The JVM on PHP
========================

[](#phpjava---the-jvm-on-php)

[![contributions welcome](https://camo.githubusercontent.com/9e93e892d0685e1bf7a1d0bd7c8410d6ecf2086a0a7b48dd58a6b96fa556ea2a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f636f6e747269627574696f6e732d77656c636f6d652d627269676874677265656e2e7376673f7374796c653d666c6174)](https://github.com/dwyl/esta/issues)[![Compatibility](https://camo.githubusercontent.com/5bc42d319ca2b02abb0f48ed0981fdba11d75c20678754774ce764918a8faacb/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f436f6d7061746962696c6974792d372e32253230616e64253230677265617465722d677265656e2e737667)](https://camo.githubusercontent.com/5bc42d319ca2b02abb0f48ed0981fdba11d75c20678754774ce764918a8faacb/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f436f6d7061746962696c6974792d372e32253230616e64253230677265617465722d677265656e2e737667)[![Build Status](https://camo.githubusercontent.com/e3492d662f7aad3fc3787d538953031856c902e0659f9c5bac57943e3cabe2df/68747470733a2f2f7472617669732d63692e6f72672f7068702d6a6176612f7068702d6a6176612e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/php-java/php-java)[![Total Downloads](https://camo.githubusercontent.com/49dbb54652ec359adc0320445d34dd7d263d6ba67ae0634fe4122584b312d49c/68747470733a2f2f706f7365722e707567782e6f72672f7068702d6a6176612f7068702d6a6176612f646f776e6c6f616473)](https://packagist.org/packages/php-java/php-java)[![License: MIT](https://camo.githubusercontent.com/784362b26e4b3546254f1893e778ba64616e362bd6ac791991d2c9e880a3a64e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d677265656e2e737667)](https://opensource.org/licenses/MIT)

[![](./docs/img/logo.png)](./docs/img/logo.png)

What is PHPJava?
================

[](#what-is-phpjava)

PHPJava is an experimental library which emulates JVM (a.k.a. Java Virtual Machine) and compiling intermediate code by PHP 🐘 And PHPJava reads binary from pre-compiled Java file(s) ☕ So, PHPJava is **NOT** bridge to Java. This library can be run 100% in PHP. This project referred to [Java Virtual Machine Specification](https://docs.oracle.com/javase/specs/jvms/se11/html/index.html) documentation at the time we made it.

We are welcoming any contributions to this project 💪

Contribution guide is here:

- [The Contribution Guide](https://github.com/php-java/php-java/wiki/The-Contribution-Guide)

Documents
---------

[](#documents)

Java Virtual Machine
--------------------

[](#java-virtual-machine)

- [English](./README.md)
- [日本語](./README-ja.md)

The Intermediate Code Compiler
------------------------------

[](#the-intermediate-code-compiler)

- [English](./docs/compiler/README.md)
- [日本語](./docs/compiler/README-ja.md)

The JVM language of PHP syntax
------------------------------

[](#the-jvm-language-of-php-syntax)

- [English](./docs/jvm-lang/README.md)
- [日本語](./docs/jvm-lang/README-ja.md)

DEMO
----

[](#demo)

[![DEMO](https://user-images.githubusercontent.com/1282995/58679222-87070880-839d-11e9-8c98-978fdd0bb015.gif)](https://user-images.githubusercontent.com/1282995/58679222-87070880-839d-11e9-8c98-978fdd0bb015.gif)

Requirements
------------

[](#requirements)

- PHP &gt;= 7.2
- Composer
- ext-zip

Run with PHPJava's binary
-------------------------

[](#run-with-phpjavas-binary)

You can run PHPJava as same as an executable binary.

### Run Class

[](#run-class)

```
./vendor/bin/PHPJava HelloWorld
```

or

```
./vendor/bin/PHPJava HelloWorld.class
```

### Run Jar

[](#run-jar)

```
./vendor/bin/PHPJava -m jar HelloWorld.jar
```

### help

[](#help)

```
./vendor/bin/PHPJava -h
```

Quick start
-----------

[](#quick-start)

1. Install PHPJava in your project:

```
$ composer require php-java/php-java:dev-master

```

2. Write Java:

```
class HelloWorld
{
    public static void main(String[] args)
    {
        System.out.println(args[0]);
    }
}
```

3. Compile Java:

```
$ javac -encoding UTF8 /path/to/HelloWorld.java

```

4. Call the main method as follows:

```
