[英](JAVA) Use Command Prompt to create .jar file from multiple .class files
I have written a .java file, called Main.java, and have compiled it using the javac in the Windows Command Prompt. 我编写了一个名为Main.java的.java文件,并使用Windows命令提示符中的javac编译它。 The compiler is creating multiple .class files (called Main.class, Main$1.class, & Main$2.class--presumably because I have anonymous inner classes in my Main.java file).
编译器正在创建多个.class文件(称为Main.class,Main $ 1.class,&Main $ 2.class - 可能是因为我在Main.java文件中有匿名内部类)。 I am trying to create a runnable .jar file so I can double click a shortcut to run this application (it is a Java Swing application), but I am unsuccessful when I navigate to the directory of the three class files and type:
我正在尝试创建一个可运行的.jar文件,因此我可以双击快捷方式来运行此应用程序(它是一个Java Swing应用程序),但是当我导航到三个类文件的目录并输入时,我不成功:
jar cfv file.jar Main.class Main$1.class Main$2.class
The Command Prompt then outputs this text: 命令提示符然后输出此文本:
added manifest
adding: Main.class(in 4871) (out = 2848)(deflated 41%)
adding: Main$1.class(in 1409) (out = 833)(deflated 40%)
adding: Main$2.class(in 1239) (out = 767)(deflated 38%)
Despite this, when I double click on the file.jar file in Windows Explorer, simply put, nothing happens. 尽管如此,当我在Windows资源管理器中双击file.jar文件时,简单地说,没有任何反应。 No swing application opens.
没有摆动应用程序打开
Hopefully someone can help me out with this. 希望有人可以帮助我解决这个问题。 Thank you
谢谢
Best...SL 最佳... SL
您需要使用入口点开关-e
(包含main()
方法的类的名称):
jar cfve file.jar Main Main.class Main$1.class Main$2.class
jar xf fileName.jar
jar xf fileName.jar
META-INF
& Copyright.mk
files META-INF
和Copyright.mk
文件 JAD.exe
from google (Its Zip File) JAD.exe
(其Zip文件) jad.exe
jad.exe
的Zip文件 jad.exe
jad.exe
的文件夹中 jad fileName.clas
s (the class filename which u want to modify) jad fileName.clas
s(要修改的类文件名) fileName.jad
file will get generate , rename it as fileName.java
fileName.jad
文件将生成,将其重命名为fileName.java
fileName.java
(if its referring to some other class file configure it in eclipse accordingly) fileName.java
(如果它引用其他类文件,则相应地在eclipse中配置它) jar cf fileName.jar
(* represents all the class files irrespective of directories) jar cf fileName.jar
(*代表所有类文件而不管目录)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.