All Projects → cstancu → netty-native-demo

cstancu / netty-native-demo

Licence: other
Instant Netty startup using GraalVM's Native Image Generation

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to netty-native-demo

Spring Native
Spring Native provides beta support for compiling Spring applications to native executables using GraalVM native-image compiler.
Stars: ✭ 2,282 (+3834.48%)
Mutual labels:  native, graalvm
native-java-examples
Native Java Apps with Micronaut, Quarkus, and Spring Boot
Stars: ✭ 44 (-24.14%)
Mutual labels:  native, graalvm
im-bass
基础IM通信
Stars: ✭ 56 (-3.45%)
Mutual labels:  netty
Multiplatform-LiveData
Multiplatorm implementation of LiveDatas / MVVM in kotlin android & native ios
Stars: ✭ 95 (+63.79%)
Mutual labels:  native
piccolo
Netty4长连接网关
Stars: ✭ 19 (-67.24%)
Mutual labels:  netty
kotlin-native-mobile-multiplatform-example
Code sharing between iOS and Android with Kotlin native
Stars: ✭ 52 (-10.34%)
Mutual labels:  native
auth0-ios-swift-sample
Auth0 Integration Samples for iOS Swift
Stars: ✭ 55 (-5.17%)
Mutual labels:  native
parcl
Gradle plugin for bundling your Java application for distribution on Windows, Mac and Linux
Stars: ✭ 52 (-10.34%)
Mutual labels:  native
netty-raknet
A reliable and high performance RakNet library designed with strict Netty patterns.
Stars: ✭ 24 (-58.62%)
Mutual labels:  netty
resp-server
Netty implementation of REdis Serialization Protocol, and a simple framework to implement command based protocols
Stars: ✭ 40 (-31.03%)
Mutual labels:  netty
IPC.Bond
IPC.Bond is an extension of IPC library that provides inter-process communication using shared memory on Windows with Bond serialization.
Stars: ✭ 26 (-55.17%)
Mutual labels:  native
twjitm-core
采用Netty信息加载实现长连接实时通讯系统,客户端可以值任何场景,支持实时http通讯、webSocket通讯、tcp协议通讯、和udp协议通讯、广播协议等 通过http协议,rpc协议。 采用自定义网络数据包结构, 实现自定义网络栈。
Stars: ✭ 98 (+68.97%)
Mutual labels:  netty
graderjs
💦 Turn your full-stack NodeJS application into a downloadable cross-platform binary. Also works for SPAs, or regular web-sites.
Stars: ✭ 147 (+153.45%)
Mutual labels:  native
tasit-sdk
A JavaScript / TypeScript SDK for making native mobile Ethereum dapps using React Native
Stars: ✭ 93 (+60.34%)
Mutual labels:  native
titanium-arkit
Use the iOS 11 ARKit API in Axway Titanium
Stars: ✭ 28 (-51.72%)
Mutual labels:  native
connor
A commandline tool for resetting Kafka Connect source connector offsets.
Stars: ✭ 17 (-70.69%)
Mutual labels:  graalvm
read
学习笔记 dubbo,rocketmq 源码解析
Stars: ✭ 33 (-43.1%)
Mutual labels:  netty
wxWidgetsTemplate
A template project for wxWidgets C++, with pre-set files and IDE projects, and allows for easy updates to wxWidgets
Stars: ✭ 13 (-77.59%)
Mutual labels:  native
windigo
Windows API and GUI in idiomatic Go.
Stars: ✭ 187 (+222.41%)
Mutual labels:  native
mjuzik
Curated Music app build on React Native
Stars: ✭ 44 (-24.14%)
Mutual labels:  native

Instant Netty startup using GraalVM's Native Image Generation

The purpose of this repository is to walk you through generating a native executable image from a simple Netty application using the GraalVM native-image tool.

Setting up the development environment

To set up your development environment you first need to download GraalVM. Either the Community Edition or the Enterprise Edition works for the purpose of this example. Note that after downloading a GraalVM release, the native-image tool needs to be installed using gu install native-image. Then you need to set your JAVA_HOME to point to GraalVM.

Now you can run the native-image tool:

> $JAVA_HOME/bin/native-image --help

GraalVM native-image building tool

This tool can be used to generate an image that contains ahead-of-time compiled Java code.
...

Alternatively, you could build native-image from source following the quick start guide.

For compilation native-image depends on the local toolchain, so please make sure: glibc-devel, zlib-devel (header files for the C library and zlib) and gcc are available on your system. On the OS that this demo was tested, Ubuntu 16.04, the following command was required to install zlib-devel, the rest of the dependencies being installed out-of-the-box:

$ sudo apt-get install zlib1g-dev

Setting up the project

For the purpose of this demo we copied the HttpHelloWorldServer example from the netty examples repo.

The example is built with Maven. The pom.xml file declares an svm.jar dependency:

<dependency>
  <groupId>com.oracle.substratevm</groupId>
  <artifactId>svm</artifactId>
  <version>19.2.0</version>
  <scope>provided</scope>
</dependency>

The svm.jar library contains all the code needed to compile the substitutions required for Netty. The other required library, graal-sdk.jar, is automatically added to the classpath when you run the javac command shipped with GraalVM.

Now you can build with:

$ mvn clean package

This will create a jar file with all dependencies embedded.

Run Netty on JVM

On the regular JVM you can run as usual using the java command:

> $JAVA_HOME/bin/java -jar target/netty-svm-httpserver-full.jar
Open your web browser and navigate to http://127.0.0.1:8080/

Run Netty with GraalVM Native Image

To build the native image we use the native-image tool:

> $JAVA_HOME/bin/native-image -jar target/netty-svm-httpserver-full.jar
Build on Server(pid: 17238, port: 45712)
[netty-svm-httpserver-full:17238]    classlist:     826.59 ms
[netty-svm-httpserver-full:17238]        (cap):     749.50 ms
[netty-svm-httpserver-full:17238]        setup:   1,375.75 ms
[netty-svm-httpserver-full:17238]   (typeflow):   5,834.62 ms
[netty-svm-httpserver-full:17238]    (objects):   5,493.09 ms
[netty-svm-httpserver-full:17238]   (features):     222.06 ms
[netty-svm-httpserver-full:17238]     analysis:  11,892.85 ms
[netty-svm-httpserver-full:17238]     (clinit):     188.83 ms
[netty-svm-httpserver-full:17238]     universe:     433.88 ms
[netty-svm-httpserver-full:17238]      (parse):     519.48 ms
[netty-svm-httpserver-full:17238]     (inline):   1,110.96 ms
[netty-svm-httpserver-full:17238]    (compile):  10,625.70 ms
[netty-svm-httpserver-full:17238]      compile:  12,985.27 ms
[netty-svm-httpserver-full:17238]        image:     910.28 ms
[netty-svm-httpserver-full:17238]        write:     185.13 ms
[netty-svm-httpserver-full:17238]      [total]:  28,682.93 ms

This creates an executable file that is abut 11 MByte in size:

> ls -Gg --block-size=k netty-svm-httpserver-full
-rwxrwxr-x 1 11328K Aug 26 20:48 netty-svm-httpserver-full

We can now run the executable:

> ./netty-svm-httpserver-full
Open your web browser and navigate to http://127.0.0.1:8080/
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].