[英]Create jar including classes and jar files
I have my program deduction.java . 我有我的程序deduction.java 。 I compiled it successfully. 我成功编译了它。 I used mysql-connector-java-5.0.8-bin.jar file at compile time. 我在编译时使用了mysql-connector-java-5.0.8-bin.jar文件。 Now I want to make single jar file which should have deduction.java and mysql-connector-java-5.0.8-bin.jar classes. 现在我想制作单个jar文件,它应该有deduction.java和mysql-connector-java-5.0.8-bin.jar类。
I used this command 我用过这个命令
jar -cvfe deduction.jar *.class
but I am not able to include mysql-connector classes. 但我无法包含mysql-connector类。 Please help to solve this. 请帮忙解决这个问题。
Actually, you should not try to regroup your dependencies into a single .jar, but instead provide them separately. 实际上,您不应该尝试将依赖项重新组合为单个.jar,而是单独提供它们。 I guess your application is a command-line executable? 我猜您的应用程序是命令行可执行文件? You have many options: 你有很多选择:
your-app/ 您的应用程序内/
/app.sh
/deduction.jar
/mysql-connector-java-5.0.8-bin.jar
And your app.sh would look like 你的app.sh看起来像
java -cp deduction.jar;mysql-connector-java-5.0.8-bin.jar deduction
Assuming the class deduction contains your main() method 假设类推导包含main()方法
Create a folder, unpack mysql-connector-java-5.0.8-bin.jar in it, add deduction.java and run 创建一个文件夹,在其中解压缩mysql-connector-java-5.0.8-bin.jar,添加deduction.java并运行
jar cvf deduction.jar *
inside this folder. 在这个文件夹里面 Or copy mysql-connector-java-5.0.8-bin.jar as deduction.jar then add deduction.java to it 或者将mysql-connector-java-5.0.8-bin.jar复制为deduction.jar,然后将deduction.java添加到其中
jar uvf deduction.jar deduction.java
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.