Pregunta

I have my program deduction.java . I compiled it successfully. I used mysql-connector-java-5.0.8-bin.jar file at compile time. Now I want to make single jar file which should have deduction.java and mysql-connector-java-5.0.8-bin.jar classes.

I used this command

jar -cvfe deduction.jar *.class

but I am not able to include mysql-connector classes. Please help to solve this.

¿Fue útil?

Solución 2

Create a folder, unpack mysql-connector-java-5.0.8-bin.jar in it, add deduction.java and run

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

jar uvf deduction.jar deduction.java 

Otros consejos

Actually, you should not try to regroup your dependencies into a single .jar, but instead provide them separately. I guess your application is a command-line executable? You have many options:

  • For example, you can group them in a folder

your-app/

    /app.sh

    /deduction.jar

    /mysql-connector-java-5.0.8-bin.jar

And your app.sh would look like

java -cp deduction.jar;mysql-connector-java-5.0.8-bin.jar deduction

Assuming the class deduction contains your main() method

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top