跳至主要內容

TOOLFK tool-online - JAVA code execution tool

This article recommends [TOOLFK] online- JAVA code execution tool, provides JAVA code online execution function.

Code teaching

This tool [online JAVA code execution tool] depends on the Docker Java image
STEP 1 interface
STEP2
The execution code is as follows
 static function dockerRunJava($code){
        $ext                       =   "java";

        preg_match("/public\s*class(.*)\s*[extends|implement]*{/",$code,$matches);
        $filename                  =   "";
        if($matches){
            $filename              =   trim($matches[1]);
        }

        list($base_url,$filename)  =   self::runWriteFile("Java",$code,$ext,$filename);
        $build_name                =   str_replace(".".$ext,"",$filename);
        $full_path                 =   $base_url."/".$filename;
        return self::dockerRun($base_url,' java:latest /bin/bash -c "javac '.$filename.' && java '.$build_name.'" ',$ext,$full_path);
    }

private static function dockerRun($base_url,$cmd,$pre,$full_path){
        $random_name    =   $pre.mt_rand(1,999999999999);
        $cmd            =   env("TOOL_DOCKER_PATH")." run --name {$random_name} --rm  -v {$base_url}:/usr/src/{$pre}  -w /usr/src/{$pre} {$cmd} 2>&1";
        $res            =   shell_exec($cmd);

        return $res;
}

 

留言

此網誌的熱門文章

BASE64-line encryption and decryption, UrlEncode encoding / decoding, native / ascii online conversion tool - toolfk online Programmer toolbox

   This paper to recommend [ToolFk] is a programmers often use a free online test kit, ToolFk feature is focused on everyday programmer development tools, without having to install any software, as long as the content execution affixed by a button, able to obtain the contents of the desired results. ToolFk also supports    BarCode Barcode generated online  ,   QueryList collector  ,   PHP code is run online  ,   PHP confusion, encryption, decryption  ,   Python code is run online  ,  JavaScript online operation  , YAML formatting tools  ,  HTTP simulation query tool  ,  HTML online toolbox  ,  JavaScript online Toolbox  , CSS online toolbox  ,  JSON online toolbox  ,  unixtime timestamp conversion  ,  Base64 / the URL of / native2ascii conversion  ,  CSV conversion kit  ,  XML online toolbox  ,...

Use PHP CURL simulate HTTP requests for online tool -toolfk online Programmer toolbox

      This paper to recommend [ToolFk] is a programmers often use a free online test kit, ToolFk feature is focused on everyday programmer development tools, without having to install any software, as long as the content execution affixed by a button, able to obtain the contents of the desired results. ToolFk also supports    BarCode Barcode generated online  ,   QueryList collector  ,   PHP code is run online  ,   PHP confusion, encryption, decryption  ,   Python code is run online  ,  JavaScript online operation  , YAML formatting tools  ,  HTTP simulation query tool  ,  HTML online toolbox  ,  JavaScript online Toolbox  , CSS online toolbox  ,  JSON online toolbox  ,  unixtime timestamp conversion  ,  Base64 / the URL of / native2ascii conversion  ,  CSV conversion kit  ,  XML online toolbox...

PHP to achieve pseudo-original free online tools - toolfk online Programmer toolbox

      This paper to recommend [ToolFk] is a programmers often use a free online test kit, ToolFk feature is focused on everyday programmer development tools, without having to install any software, as long as the content execution affixed by a button, able to obtain the contents of the desired results. ToolFk also supports    BarCode Barcode generated online  ,   QueryList collector  ,   PHP code is run online  ,   PHP confusion, encryption, decryption  ,   Python code is run online  ,  JavaScript online operation  , YAML formatting tools  ,  HTTP simulation query tool  ,  HTML online toolbox  ,  JavaScript online Toolbox  , CSS online toolbox  ,  JSON online toolbox  ,  unixtime timestamp conversion  ,  Base64 / the URL of / native2ascii conversion  ,  CSV conversion kit  ,  XML online toolbox...