I'm very new to Java. I have a single class file which is used to do some processing.
That class file is depended on a jar
. I'm very new to Java, where I'm passing the jar
to my classpath while running the program:
javac -classpath jar MyProgram.java
Now I wish to bundle both the jar
and MyProgram
into separate jar with dependency resolved.
Are there any ways to do this in Java? Note that it my MyProgram
java is only around 50 lines of code, so some simple solution will be good.
Thanks in advance.
You cannot put the library JAR inside another JAR file - Java will not be able to load classes from embedded JAR files.
You could create a JAR file containing just the classes of your application, and have the library JAR alongside it. See Packaging Programs in JAR Files for details on how to do this exactly.
If you really want everything to be in a single JAR file, you could use a tool such as One-JAR to package it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With