如何从.java文件制作JAR? [英] How do I make a JAR from a .java file?

查看:74
本文介绍了如何从.java文件制作JAR?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用具有单个框架的Java应用程序(不是具有项目的应用程序,而是项目中的应用程序; .java )编写一个简单的程序.这两个文件都是 .java ,因此我无法编写JAR所需的清单.

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,并具有主要功能,但仍然是.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

创建目录版本

从命令行运行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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆