On March 20, 2018, Java 10 was released and everybody wants to explore Java 10 but not everyone wants to change their development environment.
So in this blog, we will be discussing how can we use Java 10 using Docker.
This can be done by following simple steps given below:
- Firstly, you need to install Docker. You can install Docker from the official site of Docker.
- Open terminal.
- Create a directory jdk10docker and move into that directory.
- Make a java class JdkTen.
- Add the following code in your java class file.
- Make a text file with the name Dockerfile.
- Copy following code in the Dockerfile.
- Build docker image. It may take some time to download.
Which should result in the following output:
- Check for all the available docker images in your system using the following command:
And you will be able to see all the available images on your system.
- Run your explorejava image by using image id corresponding it.
Resulting in the following output
- Now open a new tab and check for available containers using the following command. Make sure you are in your jdk10docker directory.
Which will result in an output like this
- Now execute the container with the corresponding container id.
And Java 10 is ready to use.
You can simply compile and run your java class or you can use Java REPL just by typing jshell.
For instance,
Hope you liked the blog. Thanks for reading!
References:
docs.docker.com
docs.oracle.com
Reblogged this on Generic Class and commented:
reblogged with permission of Nancy Jain
Thanks for post