用mac终端创建一个.jar文件(转载)
2016-04-14 23:54
423 查看
1) Ensure that all necessary files are within the directory, you have opened a terminal/Command Prompt and have navigated to that directory.
2) Compile the .java class, for example HelloWorld.java with
javac HelloWorld.java
3) This will produce a .class file needed for the JAR file.
4) Next create a manifest file (saved using the extension .txt) using the text editor and input the following
Main-Class: HelloWorld
or whatever your file’s name is.
5) Next create the JAR file using this code:
jar cfm HelloWorld.jar Manifest.txt HelloWorld.class
6) Run the file:
java -jar HelloWorld.jar
另外:如果你想要创建一个包含多个文件的jar文件,参照以下方法
Following inga’s comment it’s worth noting that in order to include multiple files in the jar you need to use the:
javac *.java
followed by
jar cfm HelloWorld.jar Manifest.txt *.class
原文:
http://stackoverflow.com/questions/10125639/how-to-create-a-jar-file-using-the-terminal
2) Compile the .java class, for example HelloWorld.java with
javac HelloWorld.java
3) This will produce a .class file needed for the JAR file.
4) Next create a manifest file (saved using the extension .txt) using the text editor and input the following
Main-Class: HelloWorld
or whatever your file’s name is.
5) Next create the JAR file using this code:
jar cfm HelloWorld.jar Manifest.txt HelloWorld.class
6) Run the file:
java -jar HelloWorld.jar
另外:如果你想要创建一个包含多个文件的jar文件,参照以下方法
Following inga’s comment it’s worth noting that in order to include multiple files in the jar you need to use the:
javac *.java
followed by
jar cfm HelloWorld.jar Manifest.txt *.class
原文:
http://stackoverflow.com/questions/10125639/how-to-create-a-jar-file-using-the-terminal
相关文章推荐
- java对世界各个时区(TimeZone)的通用转换处理方法(转载)
- java-注解annotation
- java-模拟tomcat服务器
- java-用HttpURLConnection发送Http请求.
- java-WEB中的监听器Lisener
- Android IPC进程间通讯机制
- android wifi 无线调试
- Android Native 绘图方法
- Android java 与 javascript互访(相互调用)的方法例子
- 介绍一款信息管理系统的开源框架---jeecg
- 聚类算法之kmeans算法java版本
- java实现 PageRank算法
- PropertyChangeListener简单理解
- c++11 + SDL2 + ffmpeg +OpenAL + java = Android播放器
- 插入排序
- 冒泡排序
- 堆排序
- 快速排序