https://github.com/broady/gojava
Calling golang from Java
https://github.com/broady/gojava
Last synced: 20 days ago
JSON representation
Calling golang from Java
- Host: GitHub
- URL: https://github.com/broady/gojava
- Owner: broady
- Created: 2014-05-30T18:28:10.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2014-05-30T18:39:10.000Z (about 11 years ago)
- Last Synced: 2025-02-17T08:17:04.948Z (4 months ago)
- Language: Java
- Size: 188 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
gojava
======Proof of concept demonstrating how to call Go from Java.
Source files of interest:
* [Main.java](https://github.com/broady/gojava/blob/master/src/main/java/gojava/Main.java)
* [main.go](https://github.com/broady/gojava/blob/master/src/main/go/main.go)Packaging:
* Go binary is included in the jar file.At runtime:
* From Java, Go binary is extracted to a temporary directory
* From Java, the Go binary is executed
* From Go, an HTTP server is started on localhost. The address is printed to stdout.
* From Java, address is read from stdout and HTTP requests can be made to the Go program.To run the sample, which prints out the temporary file location and response body from the HTTP request:
$ ./gradlew jar && java -jar build/libs/gojava-1.0.jar
/var/folders/00/0wz20000h01000cxqpysvccm003lw8/T/goprogram7559274531365356488.tmp
from golang: hello