什么是最好的方式来打包一个Java应用程序与大量的依赖? [英] Whats best way to package a Java Application with lots of dependencies?

查看:148
本文介绍了什么是最好的方式来打包一个Java应用程序与大量的依赖?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用eclipse编写一个使用eclipse的java应用程序,它引用了一些外部jar,需要一些配置文件才能访问。



  1. 我的理解是,您不能将Jars放在另一个jar文件中,这是正确的吗?


  2. 我可以将配置文件保存在jar中,并仍然在代码中引用它们吗?还是应该配置文件的路径是命令行参数?


  3. 是否有任何第三方插件为eclipse帮助使这更容易?我正在使用蚂蚁构建文件,但我不知道我知道我在做什么。


  4. 是否有一个等同的部署Visual Studio中的项目,会弄清楚你需要的一切,只需要安装一个安装程序?我以前使用过install4j,如果没有.Net部署项目附近的自动化程序,它是强大的。


干杯。

解决方案

没有一个最佳方式。这取决于您是否正在部署swing应用程序,webstart,applet,库或Web应用程序。每个都是不同的。



点2,你是正确的。 jar文件不能包含其他jar文件。 (嗯,技术上他们可以,它的内部jar文件不会在你的类路径上,有效地意味着jar文件不包含jar文件)。



On点3,你当然可以引用jar文件外的配置文件。通常可以将配置文件引用为文件或资源。如果您使用资源方法,它通常来自类路径(可以在一个jar中)。如果你使用一个文件,那么你可以指定文件名(不在jar中)。



一般来说,大多数Java开发人员会使用 Apache Ant 实现部署。它有很好的记录,所以看看。


I'm writing a java app using eclipse which references a few external jars and requires some config files to be user accessable.

  1. What is the best way to package it up for deployment?

  2. My understanding is that you cant put Jars inside another jar file, is this correct?

  3. Can I keep my config files out of the jars and still reference them in the code? Or should the path to the config file be a command line argument?

  4. Are there any third party plugins for eclipse to help make this easier? I'm using an ant build file at the moment but I'm not sure I know what I'm doing.

  5. Is there an equivelent of the deployment projects in Visual studio, that will figure out everything you need and just make an installer? I've used install4j before, and it was powerful if no where near as automated as .Net deployment projects.

Cheers.

解决方案

There is no one 'best way'. It depends on whether you are deploying a swing application, webstart, applet, library or web application. Each is different.

On point 2, you are correct. Jar files cannot contain other jar files. (Well, technically they can, its just that the inner jar file won't be on your classpath, effectively meaning that jar files do not contain jar files).

On point 3, you certainly can reference config files outside the jar file. You can typically reference a config file as a file or a resource. If you use the resource approach, it typically comes from the classpath (can be in a jar). If you use a file, then you specify the filename (not in a jar).

In general, most Java developers would use Apache Ant to achieve deployment. Its well documented, so take a look.

这篇关于什么是最好的方式来打包一个Java应用程序与大量的依赖?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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