运行JAR文件而不直接调用`java` [英] Running a JAR file without directly calling `java`

查看:167
本文介绍了运行JAR文件而不直接调用`java`的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我部署了一个用Java编写的接受命令行参数的命令行工具。我有它打包为一个JAR文件,因为它是方便的有一个单一的文件。

I am deploying a command-line tool that is written in Java that accepts command-line arguments. I have it packaged as a JAR file because it is convenient to have a single file.

问题是,要运行它必须首先调用 java -jar(filename)(args)这是非常讨厌。

The problem is that to run it you must first call java -jar (filename) (args) and that is quite annoying.

目前的方式是有一个简单的bash脚本

The current way I have it is to have a simple bash script that launches it, but this is less than ideal.

是否还有(在Linux,Ubuntu Server中)创建一个JAR文件来调用Java VM本身?我找了一个shebang,但找不到一个(这当然是有意义,因为它是编译代码)。

Is there anyway (in Linux, Ubuntu Server) to make a JAR file that invokes the Java VM by itself? I've looked for a shebang, but couldn't find one (which of course makes sense since it is compiled code).

这是我想要做的: myprogram.jar arg1 -arg2 而不是这样: java -jar myprogram.jar arg1 -arg2

This is what I want to do: myprogram.jar arg1 -arg2 instead of this: java -jar myprogram.jar arg1 -arg2

感谢

Brian

Thanks,
Brian

推荐答案

请参阅 Linux Kernel文档中的Documentation / java.txt ,它告诉您如何配置系统使用 binfmt_misc 内核模块自动运行Jar文件。但是,这是在计算机上更改的配置选项,而不是您对jar文件所做的更改,因此它不会从系统到系统的jar文件。

See Documentation/java.txt in the Linux Kernel documentation, which tells you how to configure a system using the binfmt_misc kernel module to run Jar files automatically. However, this is a configuration option you change on a computer, not something you change about the jar file, so it doesn't follow the jar file from system to system.

这篇关于运行JAR文件而不直接调用`java`的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆