문제

Is it possible to execute a jar file by simply typing the jar name into the command line? Is there anything I can add to the manifest to achieve this?

Ie. jarname.jar instead of java -jar jarname.jar

도움이 되었습니까?

해결책

You can't really avoid that easily.

A common strategy is to deploy an executable startup script with your application; one per platform since this is platform specific (e.g. an executable shell script for Linux, and a batch script for Windows). Standard shell scripting techniques can be used to pass command line parameters to the script on to your application.

Note that there are some clever platform-specific tricks, such as the Linux one here (and I'm not certain but it may be possible to make all jars executable on the command line with some dirty registry hacks on Windows); but if you are going for platform-independence (and you don't want to have to post-process your JARs after a build), deploying a wrapper script is the way to go.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top