写好的Java文件在D盘 如何打包成jar文件
把CLASS文件打包JAR文件
答案:2 悬赏:50 手机版
解决时间 2021-04-27 11:38
- 提问者网友:世勋超人
- 2021-04-26 14:16
最佳答案
- 五星知识达人网友:北方的南先生
- 2021-04-26 14:55
We want to execute the main method in the class MyClass in the package MyPackage when we run the JAR file.
Created-By: 1.6.0 (Sun Microsystems Inc.)
Main-Class: MyPackage.MyClassWhen you run the JAR file with the following command, the main method of MyClass executes:java -jar MyJar.jar
We first create a text file named Manifest.txt with the following contents:
Main-Class: MyPackage.MyClassWarning: The text file must end with a new line or carriage return. The last line will not be parsed properly if it does not end with a new line or carriage return.We then create a JAR file named MyJar.jar by entering the following command:jar cfm MyJar.jar Manifest.txt MyPackage/*.classThis creates the JAR file with a manifest with the following contents:Manifest-Version: 1.0Created-By: 1.6.0 (Sun Microsystems Inc.)
Main-Class: MyPackage.MyClassWhen you run the JAR file with the following command, the main method of MyClass executes:java -jar MyJar.jar
全部回答
- 1楼网友:举杯邀酒敬孤独
- 2021-04-26 15:21
下载jar打包程序,一般jdk自带了
执行:
命令行:jar cvf classes.jar Foo.class Bar.class 也支持通配符. 也可以用IDE来打包,MyEclipse上带有打包选项,其它也应该支持吧.
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯