Skip to content

Instantly share code, notes, and snippets.

@asela38
Created June 5, 2019 12:16
Show Gist options
  • Save asela38/94505f908630c06c7eb9b691457097e6 to your computer and use it in GitHub Desktop.
Save asela38/94505f908630c06c7eb9b691457097e6 to your computer and use it in GitHub Desktop.
Compile and Run Hello World Java Appliation
➜ Test docker pull java
Using default tag: latest
latest: Pulling from library/java
5040bd298390: Pull complete
fce5728aad85: Pull complete
76610ec20bf5: Pull complete
60170fec2151: Pull complete
e98f73de8f0d: Pull complete
11f7af24ed9c: Pull complete
49e2d6393f32: Pull complete
bb9cdec9c7f3: Pull complete
Digest: sha256:c1ff613e8ba25833d2e1940da0940c3824f03f802c449f3d1815a66b7f8c0e9d
Status: Downloaded newer image for java:latest
➜ Test rm *.class
➜ Test cat Hello.java
public class Hello {
public static void main(String[] args) {
System.out.println("Hello, World!");
}
}
➜ Test docker run -t -i -v $(pwd):/var/java -w "/var/java" java javac *
➜ Test docker run -t -i -v $(pwd):/var/java -w "/var/java" java java Hello
Hello, World!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment