How to run the jar made from 'lein jar' command?

与世无争的帅哥 提交于 2019-12-03 10:49:37

If you're using Leiningen 1.2, you are probably being hit by a bug whereby dependencies would get deleted prior to the creation of an uberjar (obviously defeating the point of uberjar). Please either downgrade to 1.1 and wait for the new release (which should be arriving shortly) or use a checkout of lein's HEAD (as described in the section on hacking Leiningen in lein's README).

Once you do that, you should be able to produce a standalone jar with lein uberjar and say java -jar name-of-your-standalone.jar to launch your app.

As an alternative, you can create a regular jar with lein jar and say something like java -cp '$PROJECT_ROOT/lib/*:your-app.jar' your-app.main (where your-app.main is your application's main class; also, replace $PROJECT_ROOT with the appropriate path and supply a path to your-app.jar, of course). The lib/* thing will only work on JDK 1.6; with 1.5 you'd have to include every jar separately. Note that when using -jar, -cp and $CLASSPATH are ignored; only the classpath specified in the jar's manifest (if any) is taken into account.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!