简体   繁体   中英

How to create a *standalone* linux executable from java code

I know that java intent is for gui and multi platform, but the problem I'm facing it how to release a java application into a linux servers, which I don't have control on, ie I dont know what java vm is installed if at all.

So, how do i compile this into a true standalone linux exe, do not assume any pre installed package on the target linux.

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

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

    }
}

You need to specify as a requirement an installed JRE.
Otherwise you would need to deliver a JRE yourself as part of the deliverable application

The GNU COmpiler for Java does exactly this. Keep in mind that it will work properly only for small programs, either way you'll need a JVM.

There's also Avian , which has another approach and allows to deploy a lightweight JVM with jour application, but it still hasn't all the features of a full JRE.

Creating one binary from java may not be that good. You may consider tools like http://launch4j.sourceforge.net/ for creating a full installation along with appropriate jre.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM