Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
rioastamal opened this issue Nov 2, 2020 · 1 comment
Open

Comments

@rioastamal
Copy link

rioastamal commented Nov 2, 2020

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
@SharpBritannia
Copy link

SharpBritannia commented Mar 22, 2021

Maybe because in Java out is a field of System and you should access it like a field.
Console is a class of System package in .net

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants