简体   繁体   English

如何使用已经包含的外部jar导出Java项目

[英]how to export java project with external jars already included

I have created a java project using eclipse and in that project I have included a few jar files such as sqljdbc4.jar, jtds-1.2.4.jar, and log4j-1.2.17.jar. 我使用eclipse创建了一个Java项目,在该项目中,我包含了一些jar文件,例如sqljdbc4.jar,jtds-1.2.4.jar和log4j-1.2.17.jar。 I have also included a dll for windows authentication in this project. 在此项目中,我还包括用于Windows身份验证的dll。 I'm attempting to export this project as either a .zip .tar etc so the project can later be imported by someone else and work with the project. 我正在尝试将该项目导出为.zip .tar等,以便以后可以由其他人导入该项目并使用该项目。

I want to export the file in a way that the other developer can import the project and instantly begin working without having to download the jar files that the project is dependent on. 我想以其他开发人员可以导入项目的方式导出文件,并立即开始工作,而不必下载该项目所依赖的jar文件。 Is this possible at all 这有可能吗

I have already tried what i have thought would have worked going to export -> Archive file -> save in .zip format. 我已经尝试过我认为可以导出->存档文件->以.zip格式保存的内容。 I was unsuccessful with this I also figured going to properties -> Order and Export tab and selecting the needed jars would work and then exporting still unsuccessful. 我对此不成功,我也想去属性->“订购和导出”选项卡,然后选择所需的罐子即可工作,然后导出仍然不成功。

Once the other developer imports the project the jars are not there for him... 一旦其他开发人员导入了该项目,罐子就不存在了。

I would use Ant. 我会用蚂蚁。 It is integrated right into eclipse and takes an .xml file called build.xml . 它已直接集成到eclipse中,并使用一个名为build.xml的.xml文件。 It works by specifying "targets" in the xml file that each perform some action such as "build" (ie run javac ), "deploy" (ie run the jar command), etc. There is a command that can be called from within the jar target called zipgroupfileset which you can use to package all of the jars within your main jar file. 它通过在xml文件中指定“目标”来工作,每个目标都执行一些操作,例如“ build”(即运行javac ),“ deploy”(即运行jar命令)等。可以从内部调用此命令名为zipgroupfilesetjar目标,可用于将所有jar打包在主jar文件中。

More info about ant can be found here 关于蚂蚁的更多信息可以在这里找到

There are many variations on the following but the basic idea is to use a code library and share the project. 以下内容有很多变体,但是基本思想是使用代码库并共享项目。 The repository can be local to you or even better put it on an http server ( ala VisualSVN or google or the like ). 该存储库可以是您本地的,甚至最好放在http服务器上(例如VisualSVN或google之类)。

1st (local) solution: 第一种(本地)解决方案:

Install SVN ( http://subversion.apache.org/ )
Install SubVersion
Create a repo on your local file system
Share the project
Dump the repo 
Send the repo
Load the repo (Other developer)

2nd (network) solution (using google code as your library) 第二(网络)解决方案(使用Google代码作为您的库)

Install SVN ( http://subversion.apache.org/ )
Install SubVersion
Put your project on GoogleCode (http://code.google.com/)
Other developer gets project

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM