1, 下载安装JDK的docker container
我是从这个源下载已经做好的JDK8的container:
https://registry.hub.docker.com/u/dockerfile/java/
docker run -it --rm dockerfile/java:oracle-java8
2, 添加GUI支持
有好几种方案,我使用的是这种:
http://fabiorehm.com/blog/2014/09/11/running-gui-apps-with-docker/
还有一种是:
https://pelle.io/2014/07/11/delivering-gui-applications-with-docker/
我没有试过。
3,安装swt-gtk
但是这时候运行swt程序,还是会抛如下错误:
java.lang.UnsatisfiedLinkError: Could not load SWT library. Reasons: no swt-gtk-3740 in java.library.path no swt-gtk in java.library.path Can‘t load library: /home/gabriel/.swt/lib/linux/x86_64/libswt-gtk-3740.so
Can‘t load library: /home/gabriel/.swt/lib/linux/x86_64/libswt-gtk.so
需要:
1) 添加architecture i386
sudo dpkg --add-architecture i386
sudo apt-get update
参考:
http://askubuntu.com/questions/551840/unable-to-locate-package-libc6-dbgi386-in-docker
2)安装gtk
sudo apt-get install libgtk2.0-0:i386
参考:
http://askubuntu.com/questions/232691/cannot-open-shared-object-file-no-such-file-or-directory
3)安装swt支持
sudo apt-get install libswt-gtk-3-jni libswt-gtk-3-java
并拷贝到
sudo cp /usr/lib/jni/libswt-*3740.so ~/.swt/lib/linux/x86_64/