executing java -jar via classpath vs in the jar file dir

前端 未结 2 883
独厮守ぢ
独厮守ぢ 2021-01-27 06:19

After having used NetBeans to create a Java program call it Addition and then having successfully cleaned and built an Executable Jar File in a folder c:\\Users\\Ben\\Doc\\NetBe

2条回答
  •  萌比男神i
    2021-01-27 06:52

    because java doesn't look in classpath to launch jar file for this command it needs file as input

    so if you set the directory where your jar file is placed and try to execute java -jar command and expect it to pick up jar from that directory because it is in classpath it is not valid

    you can give full path to jar like from any directory

    java -jar c:\Users\Ben\Doc\NetBeansProjects\Addition\dist\Addition.jar
    

提交回复
热议问题