如何从 .java 文件制作 JAR? [英] How do I make a JAR from a .java file?
问题描述
我正在使用具有单个框架的 Java 应用程序(不是具有项目的应用程序,而是项目中的应用程序;.java)编写一个简单的程序.这两个文件都是 .java 所以我不能写一个 JAR 需要的 manifest.
I was writing a simple program using a Java application (not application that has projects, but application within a project; .java) that has a single frame. Both of the files are .java so I can't write a manifest needed by the JAR.
MyApp.java 就像一个带包的类,然后导入公共类 MyApp
并有一个 main 函数,但它仍然是 .java 文件!如果有帮助,我会在 JDeveloper 11g 中编写它.
The MyApp.java starts like a class with package, imports then public class MyApp
and has a main function, but it's still .java file! I'm writing it in JDeveloper 11g if it helps.
任何想法如何从这些文件制作 JAR?
Any ideas how to make a JAR from these files?
推荐答案
打开命令提示符.
转到您的 .java 文件所在的目录
Go to the directory where you have your .java files
创建目录build
从命令行运行java编译
Run java compilation from the command line
javac -d ./build *.java
如果没有错误,在构建目录中你应该有你的类树
if there are no errors, in the build directory you should have your class tree
移动到构建目录并执行
jar cvf YourJar.jar *
用于添加清单检查 jar 命令行开关
For adding manifest check jar command line switches
这篇关于如何从 .java 文件制作 JAR?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!