[英]some problem in jar file in java
I have created jar file for my project. 我为我的项目创建了jar文件。 It is running successfully.
它运行成功。 There is one 'lib' folder.
有一个'lib'文件夹。 I have other jar files in this folder.
我在这个文件夹中有其他jar文件。 I added all these jar files in MANIFEST.MF in the jar as follows:
我在jar中的MANIFEST.MF中添加了所有这些jar文件,如下所示:
>>Class-Path:jar file names .... ... ....
I run jar file as follows: 我运行jar文件如下:
>>java -jar jarfile.jar arguments...
but problem is that I need to put this jar file where the 'lib' folder is located, and if i want to run this jar on others machine,then i need to give this jar folder along with 'lib' folder. 但问题是我需要将此jar文件放在'lib'文件夹所在的位置,如果我想在其他机器上运行此jar,那么我需要将此jar文件夹与'lib'文件夹一起提供。
but I dont want to give this jar along with 'lib' folder. 但我不想把这个jar和'lib'文件夹放在一起。
And when I try to put this jar outside the 'lib' folder,it is not working. 当我尝试将这个jar放在'lib'文件夹之外时,它无法正常工作。
I have to give this only jar folder to other machine.so I can run my jar file on others machine. 我必须将这个jar文件夹只给其他机器。所以我可以在其他机器上运行我的jar文件。
I'm sorry to tell you, but unless you implement your own custom class loader, you can not nest jar-files like that in Java. 很抱歉告诉你,但除非你实现自己的自定义类加载器,否则你不能在Java中嵌套这样的jar文件。 See for instance this discussion .
例如,参见本讨论 。
You could however merge your jar files using tools such as One-Jar . 但是,您可以使用One-Jar等工具合并 jar文件。
Related answer . 相关答案 。
( woho, this was my 1000th answer :) ( woho,这是我的第1000个答案 :)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.