1. Compile Scala and Create a Jar File
Just follow the instuction here then you can create a jar file: https://stackoverflow.com/questions/1082580/how-to-build-jars-from-intellij-properly
Note that if you are using Maven, set META-INF directory under main/resources folder instead of main/java. Refer the link: https://intellij-support.jetbrains.com/hc/en-us/community/posts/206872335-How-to-create-executable-JAR-using-Intellij-
2. Run Docker Container with Java 8
Here is the official repository for OpenJDK docker image.
https://hub.docker.com/_/openjdk/
You can pull the docker image to your local repository.
docker pull openjdk:latest
Then, run a new container from the image.
[root@sunny ~]# docker run -it openjdk:latest bash;
root@6c5fbb0f16c3:/#
Check the version of Java
root@6c5fbb0f16c3:/# java -version
openjdk version "1.8.0_141"
OpenJDK Runtime Environment (build 1.8.0_141-8u141-b15-1~deb9u1-b15)
OpenJDK 64-Bit Server VM (build 25.141-b15, mixed mode)
Also, you can check the status of running docker containers with docker ps
command.
[root@sunny ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
6c5fbb0f16c3 openjdk:latest "bash" 17 minutes ago Up 17 minutes
3. Run Jar Application on Container
You can copy files in the docker host onto a docker conainer using docker cp
command: https://docs.docker.com/engine/reference/commandline/cp/
[root@sunny ~]# docker cp ./test.jar 6c5fbb0f16c3:/home/test.jar
Finally, run the jar as usual.
(I used an app which send get request to Isilon REST API for the test.)
root@6c5fbb0f16c3:/# java -jar /home/test.jar
Sending HTTP Request to https://10.32.2.26:4088/platform/3/statistics/summary/drive
_platform_3_statistics_summary_drive