Java – How to create a *standalone* Linux executable from Java code

How to create a *standalone* Linux executable from Java code… here is a solution to the problem.

How to create a *standalone* Linux executable from Java code

I know that

Java is intended for GUI and multiplatform, but the problem I face is how to publish java applications into linux servers that I have no control over, i.e. I don’t know what a java vm is installed, if any.

So, how do I compile it into a true standalone linux exe, without assuming there are any pre-installed packages on the target linux.

public class MyTest {
    public static void main(String[] args) {

System.out.println("You passed in: " + args[0]);

}
}

Solution

You need to specify an installed JRE.
Otherwise, you will need to deliver the JRE yourself as part of the deliverable application

Related Problems and Solutions