/jdk11-mvn-py3-X11

OpenJDK Java 11 + Maven + Python 3 + Yarn + Node/NPM

Primary LanguageShellApache License 2.0Apache-2.0

OpenJDK Java 11 + Maven 3 + Python 3 + pip 21 + node 16 + npm 6 + Gradle 6 + X11 (Desktop GUI)

Components:

RUN

./run.sh

or

make up

BUILD

./build.sh

or

make build

Pull the image from Docker Repository

docker pull openkbs/jdk11-mvn-py3-x11

Base the image to build add-on components

FROM openkbs/jdk11-mvn-py3-x11

Run the image

Then, you're ready to run:

  • make sure you create your work directory, e.g., ./data
mkdir ./data
docker run -d --name my-jdk11-mvn-py3-x11 -v $PWD/data:/data -i -t openkbs/jdk11-mvn-py3-x11

Disposal-able Web Browsers using X11 Container - one of Possible Other Usages

You can use this X11 Container as your "isolated Container for your internet browsing - while keep the safety (security) of HOST computer. And, you can just do below (in the future, a slim-version of this X11 only browsers will be created for just this purpose with security locked down removing sudo and other measures - to just use this Container as Docker-based Browser for more safety in browsing the Internet) to prevent using your HOST's PC/laptop to expose your HOST computer to

./run.sh firefox

or

./run.sh google-chrome --no-sandbox

To lunch multiple X11 Desktop applications

Default is to show xeyes (X11 app) when using "docker-compose up" or "make up". You can use another host's teminal to enter the Container to start run, say, Firefox or Google-Chrome:

./shell.sh 

(once you enter the Container - while you have another terminal have xeyes running)

firefox

or

google-chrome --no-sandbox 

Build and Run your own image

Say, you will build the image "my/jdk11-mvn-py3-x11".

docker build -t my/jdk11-mvn-py3-x11 .

To run your own image, say, with some-jdk11-mvn-py3-x11:

mkdir ./data
docker run -d --name some-jdk11-mvn-py3-x11 -v $PWD/data:/data -i -t my/jdk11-mvn-py3

Shell into the Docker instance

docker exec -it some-jdk11-mvn-py3-x11 /bin/bash

Run Python

To run Python code

docker run -it --rm openkbs/jdk11-mvn-py3-x11 python3 -c 'print("Hello World")'

or,

docker run -i --rm openkbs/jdk11-mvn-py3-x11 python3 < myPyScript.py

or,

mkdir ./data
echo "print('Hello World')" > ./data/myPyScript.py
docker run -it --rm --name some-jdk11-mvn-py3-x11 -v "$PWD"/data:/data openkbs/jdk11-mvn-py3-x11 python3 myPyScript.py

or,

alias dpy3='docker run --rm openkbs/jdk11-mvn-py3-x11 python3'
dpy3 -c 'print("Hello World")'

Compile or Run java while no local installation needed

Remember, the default working directory, /data, inside the docker container -- treat is as "/". So, if you create subdirectory, "./data/workspace", in the host machine and the docker container will have it as "/data/workspace".

#!/bin/bash -x
mkdir ./data
cat >./data/HelloWorld.java <<-EOF
public class HelloWorld {
   public static void main(String[] args) {
      System.out.println("Hello, World");
   }
}
EOF
cat ./data/HelloWorld.java
alias djavac='docker run -it --rm --name some-jdk11-mvn-py3-x11 -v '$PWD'/data:/data openkbs/jdk11-mvn-py3-x11 javac'
alias djava='docker run -it --rm --name some-jdk11-mvn-py3-x11 -v '$PWD'/data:/data openkbs/jdk11-mvn-py3-x11 java'

djavac HelloWorld.java
djava HelloWorld

And, the output:

Hello, World

Hence, the alias above, "djavac" and "djava" is your docker-based "javac" and "java" commands and it will work the same way as your local installed Java's "javac" and "java" commands. However, for larger complex projects, you might want to consider to use Docker-based IDEs as listed in the later sections of this document.

Python Virtual Environments

There are various ways to run Python virtual envrionments, for example,

Setup virtualenvwrapper in $HOME/.bashrc profile

Add the following code to the end of ~/.bashrc

#########################################################################
#### ---- Customization for multiple virtual python environment ---- ####
#########################################################################
export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3
source /usr/local/bin/virtualenvwrapper.sh
export WORKON_HOME=~/Envs
if [ ! -d $WORKON_HOME ]; then
    mkdir -p $WORKON_HOME
fi

To create & activate your default venv environment, say, "my-venv":

mkvirtualenv my-venv
workon my-venv

See Also - Docker-based IDE

See Also - Docker-based SQL GUI

Other Java Dev in Docker

Display X11 Issue

More resource in X11 display of Eclipse on your host machine's OS, please see

Other possible Issues

You might see the warning message in the launching xterm console like below, you can just ignore it. I googles around and some blogs just suggested to ignore since the IDE still functional ok.

Releases information