Embedded Java in Bash
Java is the backend solution for several companies, mainly for services and microservices. However, when you need to ship java for a CLI or DevOps solution java is a bit verbose. First, because you need to have a JDK, and second java by default is not self-contained. Meaning you will java multiple jars and if you are not running on a standalone server or using a framework like Spring Boot this could be a bit annoying. There are other solutions like you could be doing a Uber Jar or Fat Jar where you can bundle your app + dependencies in one and one jar. Today I want to share a bash trick where we can embed a Java jar into a single bash script. This trick is neat because with a single file we can combine bash and java.
The Video
The Code
https://github.com/diegopacheco/java-pocs/tree/master/pocs/self-executable-bash-java
Cheers,
Diego Pacheco