如何托管与python pypi.org类似的Java应用程序包,以便用户可以通过命令行安装并使用它?
我有一个Java应用程序,我想在某种免费的托管网站上托管。稍后,用户可以通过命令行工具安装该应用程序并轻松使用。
在搜索时,我发现可以通过 https://pypi.org/ python 代码>应用程序,但不确定如何为Java应用程序执行相同的操作。
有人知道是否有一种方法可以实现Java应用程序类似的方法?
以下是我在应用程序中拥有的示例代码:
public class Operations {
public static BigDecimal add(final BigDecimal a, final BigDecimal b) {
return a.add(b);
}
public static BigDecimal subtract(final BigDecimal a, final BigDecimal b) {
return a.subtract(b);
}
public static BigDecimal multiply(final BigDecimal a, final BigDecimal b) {
return a.multiply(b);
}
public static BigDecimal divide(final BigDecimal a, final BigDecimal b) {
return a.divide(b);
}
}
我想将程序生成的代码或JAR发布到某种存储库中,以便用户可以通过命令行安装此应用程序并将其直接在其命令行中使用,而不是添加依赖关系仅在Java IDE中使用。
请让我知道如何实现这一目标?我不确定是否可用或是否可以实现。我在这里发布以获取专家的一些选择,因为我是这些事情的新手。
I have a Java application which I would like to host on some sort of free hosting website. Later, users can install that application via a command-line tool and use it easily.
While searching I found that its possible to do via https://pypi.org/ for Python
applications but not sure how to do the same for Java applications.
Does anyone know if there is a way to achieve something similar for Java application?
Following is the example code I have in my application:
public class Operations {
public static BigDecimal add(final BigDecimal a, final BigDecimal b) {
return a.add(b);
}
public static BigDecimal subtract(final BigDecimal a, final BigDecimal b) {
return a.subtract(b);
}
public static BigDecimal multiply(final BigDecimal a, final BigDecimal b) {
return a.multiply(b);
}
public static BigDecimal divide(final BigDecimal a, final BigDecimal b) {
return a.divide(b);
}
}
I would like to publish this code or JAR generated by the program into some sort of repository so users can install this application via command line and use it directly in their command line instead of adding dependency and use only in Java IDE.
Please let me know how can I achieve this? I am not sure if this is available or if its possible to achieve. I am posting here to get some options from expert as I am quite new to these things.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我知道Java应用程序可以是CLI工具,但我想了解您的特定帖子。
是否是CLI工具?如果是CLI工具(您已经编写的应用程序),则应将其作为完整的软件包发布(例如,可以下载和执行的zip/tar.gz存档)。
如果需要自动安装工具,则应检查诸如install4j,jdk的jpackager之类的内容。
如果是库,则应将其发布到中央存储库中( https://central.sonatype.org/ ),因此可以用作依赖项通常。
问题一直存在:下载应该使用哪种工具?默认情况下没有这样的工具...您可以使用curl/wget或like下载,但它不会进行安装。甚至您自己的浏览器都可以下载工件...
I know that an Java app can be an CLI tool but I would like to know about your particular post.
Is it a cli tool or not? If it's a CLI tool (Application you have written) it should be published as a complete package (for example as ZIP/tar.gz archive which can be downloaded and executed).
If you need an automatic installation tool you should check for things like install4j, jpackager of the JDK etc.
If it's a library it should be published into central repository (https://central.sonatype.org/) so it can be used as a dependency as usual.
The question keeps: which tool should do the download ? There is no such tool by default ... you can use curl/wget or alike to download but it will not do the installation..or even your own browser to download an artifact...