Giter VIP home page Giter VIP logo

min-jdk-rt's Introduction

POC for custom jdk 11 runtime

Prerequesites

  • docker
  • make

Usage

make

Result

  • Reduction from 308MB to 29MB
conni@herbie:~/work/conni/github/cbuschka/min-jdk11-rt [master]$ make
*****************************
* cleaning...
*****************************
rm -rf /home/conni/work/conni/github/cbuschka/min-jdk11-rt/target/
*****************************
* building build container...
*****************************
docker build -t min-jdk11-rt /home/conni/work/conni/github/cbuschka/min-jdk11-rt \
	&& docker run -v /home/conni/work/conni/github/cbuschka/min-jdk11-rt:/work -u 1000:1001 min-jdk11-rt make clean link
Sending build context to Docker daemon  118.3kB
Step 1/4 : FROM openjdk:11-jdk
 ---> a7e47afa852b
Step 2/4 : RUN export DEBIAN_FRONTEND=noninteractive; 	apt-get update 	&& apt-get install make binutils         && apt-get autoremove -y         && rm -rf /var/lib/apt/lists/*
 ---> Using cache
 ---> 3a5c4acd884b
Step 3/4 : RUN mkdir -p /work
 ---> Running in 501acfa74ffe
Removing intermediate container 501acfa74ffe
 ---> b37df903448f
Step 4/4 : WORKDIR /work
 ---> Running in 81fbc50857c1
Removing intermediate container 81fbc50857c1
 ---> f9357e587e15
Successfully built f9357e587e15
Successfully tagged min-jdk11-rt:latest
*****************************
* cleaning...
*****************************
rm -rf /work/target/
*****************************
* compiling...
*****************************
cd /work/src \
	&& /usr/local/openjdk-11/bin/javac -d /work/target/classes ./module-info.java \
	&& /usr/local/openjdk-11/bin/javac -d /work/target/classes --module-path /work/target/classes ./hello/Hello.java
*****************************
* packaging...
*****************************
cd /work/target/classes && /usr/local/openjdk-11/bin/jar cvf /work/target/hello.jar .
added manifest
added module-info: module-info.class
adding: hello/(in = 0) (out= 0)(stored 0%)
adding: hello/Hello.class(in = 422) (out= 291)(deflated 31%)
*****************************
* linking runtime...
*****************************
/usr/local/openjdk-11/bin/jdeps --module-path /work/target/classes -s --module hello
hello -> java.base
# https://github.com/docker-library/openjdk/issues/217
# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=905575
# https://bugzilla.redhat.com/show_bug.cgi?id=1652177, --native-libs-replace 
/usr/local/openjdk-11/bin/jlink --verbose --strip-debug --compress 2 --no-header-files --no-man-pages --module-path /usr/local/openjdk-11/jmods/:/work/target/classes --add-modules hello --output /work/target/dist/
hello file:///work/target/classes/
java.base file:///usr/local/openjdk-11/jmods/java.base.jmod

Providers:
  java.base provides java.nio.file.spi.FileSystemProvider used by java.base
strip -p --strip-unneeded /work/target/dist/lib/server/libjvm.so
du -sh /usr/local/openjdk-11
308M	/usr/local/openjdk-11
du -sh /work/target/dist
29M	/work/target/dist
*****************************
* running...
*****************************
times ./target/dist/bin/java -cp target/hello.jar hello.Hello
0m0.002s 0m0.001s
0m0.000s 0m0.000s

License

MIT

min-jdk-rt's People

Contributors

cbuschka avatar

Watchers

James Cloos avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.