JavaArchive
PHPJava\Core\JavaArchive
Introduction
JavaArchive class is provided APIs for executing .jar file.
How to use
For an example as follows:
- Write Java:
class HelloWorld { public static void main(String[] args) { System.out.println(args[0]); } }
- Compile classes to an archive.
$ javac -encoding UTF8 -d build src/*
$ cd build && jar -cvfe ../Test.jar Test *
- Write PHPJava:
<?php use PHPJava\Core\JavaArchive; // You must pass parameters to entrypoint within the `execute` method. // The `execute` method haven't default parameters. (new JavaArchive('Test.jar')) ->execute(["Hello World!"]); // or (new JavaArchive('Test.jar')) // Specify Test.class on JavaArchive ->getClassByName('Test') ->getInvoker() ->getStatic() ->getMethods() ->call( 'main', ["Hello World!"] );
You'll get a result Hello World!
Provided methods
Name
public function __construct(string $jarFile, array $options = [])
Introduction
TBD
Parameters
No parameters.
Name
public function __destruct()
Introduction
TBD
Parameters
No parameters.
Name
public function execute(...$arguments)
Introduction
TBD
Parameters
No parameters.
Name
public function __debugInfo()
Introduction
TBD
Parameters
No parameters.
Name
public function getVersion(): ?string
Introduction
TBD
Parameters
No parameters.
Name
public function getCreatedBy(): ?string
Introduction
TBD
Parameters
No parameters.
Name
public function getEntryPointName(): ?string
Introduction
TBD
Parameters
No parameters.
Name
public function getClassPaths(): array
Introduction
TBD
Parameters
No parameters.
Name
public function getClasses(): array
Introduction
TBD
Parameters
No parameters.
Name
public function getClassByName(string $name): JavaClassInterface
Introduction
TBD
Parameters
No parameters.