how to create a runnable jar file from command line similar to eclipse

假装没事ソ 提交于 2019-12-04 10:27:52

there's no way do this kind of thing from the jar command line utility. there are 3 main solutions to the dependencies problem:

  1. in your MANIFEST.MF you may reference other jar files as part of your classpath and then people could invoke your code using java -jar [just your jar] and your dependencies will be picked up
  2. you can package your code and dependencies into a fat jar (which is what youre describing). usually you just convert your project to use some build tool (more advanced than simple javac and jar) and configure the tool. for example with maven. see 2 different approaches here and here
  3. (again with a build tool) you can use something better than a fat jar - use one-jar. the difference is that with a fat jar you run the risk of files with the same name in different libraries "colliding"
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!