I generated .class files by the following command:
javac -cp \directoryName\external.jar myPackageDirectory\First.java myPackageDirectory\Second.java
I needed to use -cp
during compilation and name of .jar file of an "external" library (external.jar) to be able to use this library from my code.
Using my .class files I have generated my .jar file in the following way:
jar cfm app.jar manifest.txt myPackageDirectory\*.class
manifest.txt
contains just one line:
Main-Class: myPackageName.First
My problem is that I am not sure that I will be able to run my .jar file on other computers. I think so because during the compilation I specified the location of the .jar file of the external library. So, my .class files (included into the .jar file will try to find the .jar file of the external library in a specific directory and there is no guaranty that that the .jar file of the external library will be in the same directory as on the my computer.
I heard that the above problem can be solved by a
usage of a MANIFEST file that I include in my own jar, and which will list dependency locations
but I do not understand how it works. I do need to specify location of the "external.jar" at the compilation stage (otherwise the compiler complains).