Skip to content

Instantly share code, notes, and snippets.

@igor-kupczynski
Created November 11, 2018 20:06
Show Gist options
  • Save igor-kupczynski/d6d9969bca25d98958dd2fd0f7bd208b to your computer and use it in GitHub Desktop.
Save igor-kupczynski/d6d9969bca25d98958dd2fd0f7bd208b to your computer and use it in GitHub Desktop.
Dockerizing windwos java 32 bit JNI app

This is a complementary material to my blog post: Use wine to run windows JDK on linux. Please check the blogpost for detail on what and why happens here.

Before building the container:

  • Place the downloaded jdk-8u191-windows-i586.exe in the same folder as Dockerfile (or if using different JVM version, just adjust the filename).
FROM ubuntu:18.10
RUN dpkg --add-architecture i386 && \
apt-get update && \
apt-get install -y wine32 && \
apt-get clean -y
COPY jdk-8u191-windows-i586.exe /app/jdk.exe
RUN chmod +x /app/jdk.exe && wine /app/jdk.exe /s
LABEL = wine-jdk8-32:2018-11-11
ARCHIVE="wine-jdk8-32"
.PHONY: help
help:
@echo "build - image $(LABEL)"
@echo "save-image - to $(ARCHIVE).tar.gz"
@echo "load-image - from $(ARHIVE).tar.gz"
.PHONY: build
build:
docker build . -t $(LABEL)
save-image:
docker save $(LABEL) > $(ARCHIVE).tar
gzip $(ARCHIVE).tar
load-image:
gunzip $(ARCHIVE).tar.gz
docker load < $(LABEL).tar
#!/bin/bash
export DOCKER_IMG="wine-jdk8-32:2018-11-11"
export JAVA_EXE='c:\Program Files\Java\jdk1.8.0_191\bin\java.exe'
export JAR='legacy-app.jar'
export JNA='lib/win32'
export MAIN_CLASS='com.legacy.MainClass'
docker run --rm -v "$PWD:/build" -w /build -it "$DOCKER_IMG" wine "$JAVA_EXE" -cp "$JAR" -Djna.library.path="$JNA" "$MAIN_CLASS"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment