简体   繁体   中英

Java - Arguments in Jar File executable

Basically I've created a jar file, but I want it to have precreated arguments.

Eg like the below add ons.

-Xmx256m

The problem is I'm not too sure how to make it so this is embedded into the Jar file let alone if it's even possible. I'm asking for it to not require a batch or command prompt addition, but to simple remain clickable as a jar file. Then add the extra arguments I desired upon clicking. Would this be a manifest modification possibly?

I've been searching Google and other links on this website with very little luck to the answer I desire.

There is no way to make a clickable jar with JVM settings. After you double click it, you're calling "java -jar" and then your JVM will be running before reading jar contents.

I don't think this is possible for JVM args without some hackery. The reason being that the JVM instance is already initialized by the time you get to the main() method.

A potential hack would be to change your main method to make a System call to spawn another java process with the arguments you desire.

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