V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
tobychen1991
V2EX  ›  Java

如何启动一个 jar 包里面的 main 方法

  •  
  •   tobychen1991 · 2019-07-29 15:13:08 +08:00 · 3681 次点击
    这是一个创建于 1733 天前的主题,其中的信息可能已经有所发展或是发生改变。

    不依赖 Springboot,但依赖了其他 jar 包,不能单 class 文件运行。请大神教教萌新

    5 条回复    2019-07-29 21:46:02 +08:00
    wdmx007
        1
    wdmx007  
       2019-07-29 15:18:19 +08:00
    maven 的话:
    maven-jar-plugin 和 maven-assembly-plugin 了解一下
    arrow8899
        2
    arrow8899  
       2019-07-29 15:22:27 +08:00
    java -cp your_jar_file.jar your.package.name.YourClass
    tobychen1991
        3
    tobychen1991  
    OP
       2019-07-29 15:36:02 +08:00
    @wdmx007 谢谢,可以了
    jay0726
        4
    jay0726  
       2019-07-29 21:31:26 +08:00
    jay0726
        5
    jay0726  
       2019-07-29 21:46:02 +08:00
    @jay0726 #4 csdn 广告太多 可以直接看他的个人博客文章 http://xxgblog.com/2015/08/07/maven-create-executable-jar/
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   4649 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 09:59 · PVG 17:59 · LAX 02:59 · JFK 05:59
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.