Skip to content

How to call Java Standard Libraries in JPHP Like in PeachPie (.NET)? #417

@rioastamal

Description

@rioastamal

I can do this in PeachPie (PHP Compiler for .NET) which is basically calling .NET standard libraries.

<?php
use \System\Console;
use \System\IO\StreamReader;
use \System\Net\WebRequest;

function main()
{
    $uri = $_SERVER['argv'][1];

    $http = WebRequest::Create($uri);
    $response = $http->GetResponse();
    $stream = new StreamReader( $response->GetResponseStream() );
    
    Console::WriteLine( "HTTP Response:\n" . $stream->ReadToEnd() );
}

main();

How to do call Java standard libraries like the one above? I've tried this one.

<?php

function main() {
    \System\out::println("Hello World\n");
}

main();

But it gives me.

$ jppm start
-> linux
-> app:run
-> install

Fatal error: Uncaught Error: Class 'System\out' not found in res://index.php on line 4, position 12
Stack Trace:
#0 <internal>() called at [res://index.php:1]
#1 main() called at [res://index.php:7]
#2 {main}
  thrown in res://index.php on line 4

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions