- java 1.7+
- golang 1.6+
- maven
git clone [email protected]:flowbehappy/call_go_from_java.git
cd call_go_from_java
sh build_go.sh
# mvn jnaerator:generate
build_go.sh- compiles thetest.gointo a c dynamic lib, put intlibfolder.mvn jnaerator:generate- generates the jna Java classes by jnaerator. Note that somehow in Greate China nativelibs4java.sourceforge.net is likely blocked, this script may fail to download themaven-jnaerator-plugin. Consider using an VPN. And you don't need to run this script if you haven't modified the export methods in test.go.
It is a maven project. Import this project into your favourite dev environment. Compile and run TestCallGolang.