1 2. Atitit call another call each other between the language of the feature directory 1. Waht common language java python js sql xml h5 c # php, etc. Why do we need to call each other why 1 3. Chang

Atitit another language function calls

 

table of Contents

Call each other between 1 1. Waht common language java python js sql xml h5 c # php, etc.

2. Why do I need to call each other why 1

3. Common mode how, 2

3.1. Internal interpreter language parser Mode 2 Mode api

3.2. Cli Mode 2

3.3 Remote Interface Mode ws rest ajax like 2

3.4 host interface call mode register 2

4. Java call python 2

4.1. Python call java 3

4.2. Sql call other languages ​​3

5. Table 3 Comparative major languages

6. Console some internal specification of console 4

6.1 Standard output stdin, stdout and error output 4

6.2. The principle is to execute the command input characters to the console reads the output 4

7. The blocking api programs and sub-line 4

8. faced with common problems to solve 4

9. ref 4

 

 

  1. Waht call each other between the common language java python js sql xml h5 c # php, etc.

 

  1. Why do I need to call each other why

Enhance readability

Improve performance, equivalent to the library to write high-performance language

Learn from each other, enhance flexibility in areas such as capacity

Reduce duplication of code in the project of common

Isolated native microService

Improve service stability

 

  1. Common mode how,
    1. Api internal language interpreter mode parser mode

Java calls sql. .

Java calls xml h5, mybatis calls inside the sql xml

    1. Cli mode  
    2. The remote interface mode ws rest ajax, etc.

 

    1. Host interface call registration mode
  1. Java calls python

/bookmarksHtmlEverythingIndexPrj/src/aaa/invokeLan.java

import java.io.BufferedInputStream;

import java.io.IOException;

 

import org.apache.commons.io.IOUtils;

 

public class invokeLan {

 

public static void main(String[] args) throws IOException {

String command = "python D:\\zzz\\py.py";

 

 String rzt = IOUtils.toString(Runtime.getRuntime().exec(command).getInputStream(),"gbk");

 System.out.println(rzt);

 

}

 

}

 

    1. Python call java

os.popen ()

    1. Sql call other languages

Mainly used to write udf, sp

 

  1. The major language comparison table

Language

method

java

Runtime.getRuntime().exec(

Python

Os.popen ()

Php

exec()

C#

Process。StandardInput.WriteLine(command)

Js (node ​​environment

child_processexec()

 

 

 

 

 

 

  1. Console console of some internal norms

Console Console ,

    1. Standard output stdin, stdout  and error output
    2. Principle execution of the command is to read input characters to the console output

Process。StandardInput.WriteLine(command)

 

  1. Api blocking programs and sub-line
  2. Common Problems and Solutions

Output code reader

Parameter object serialization

Read a long output   

Read asynchronous mode

  1. ref

python cmd command calls - launched into the cannon brother - blog Park .html

Guess you like

Origin blog.csdn.net/attilax/article/details/91519669