java文件打包jar文件
① java 多个类文件如何打包成jar
java多个类文件可以使用Myeclipse来打包成jar包,首先打开Myeclipse创建一个java项目,然后把类文件导入到项目下,然后右键点击项目名,选择Export导出,选择jar包导出,然后选择导在哪个目录下即可。使用Myeclipse还可以导出javaWeb项目,按照war导出javaWeb项目。
② 用java代码把txt文件自动打包到jar文件中,如何做 谢谢!
如认可,请您赏分30分,谢谢
命令行参数:
args[0] 待打包的完整文件路径
args[1] jar 输出文件的完整路径
import java.io.*;
import java.util.zip.*;
/**
* @author Hardneedl
*/
public class JarPacker {
public static void main(String[] args) {
File inFile = new File(args[0]);
ZipEntry zipEntry = new ZipEntry (inFile.getName());
try {
InputStream ins = new FileInputStream(inFile);
byte[]datas = new byte[ins.available()];
ins.read(datas);
ins.close();
ZipOutputStream zout = new ZipOutputStream(new FileOutputStream(args[1]));
zout.putNextEntry(zipEntry);
zout.write(datas);
zout.closeEntry();
zout.finish();
zout.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}
③ 如何通过命令行将java文件打包成jar
先打开命令提示符(win2000或在运行框里执行cmd命令,win98为DOS提示符),输入jar Chelp,然后回车(如果你盘上已经有了jdk1.1或以上版本),看到什么:
用法:jar {ctxu}[vfm0Mi] [jar-文件] [manifest-文件] [-C 目录] 文件名 ...
选项:
-c 创建新的存档
-t 列出存档内容的列表
-x 展开存档中的命名的(或所有的〕文件
-u 更新已存在的存档
-v 生成详细输出到标准输出上
-f 指定存档文件名
-m 包含来自标明文件的标明信息
-0 只存储方式;未用zip压缩格式
-M 不产生所有项的清单(manifest〕文件
-i 为指定的jar文件产生索引信息
-C 改变到指定的目录,并且包含下列文件:
如果一个文件名是一个目录,它将被递归处理。
清单(manifest〕文件名和存档文件名都需要被指定,按'm' 和 'f'标志指定的相同顺序。
示例1:将两个class文件存档到一个名为 'classes.jar' 的存档文件中
④ java怎么让文件打包成jar
右键 export,选择java-->jar file
这个是选择你导出的路径 点击browse选择好路径就ok了
⑤ 如何将带包的java项目文件打包成jar
用法:jar {ctxu}[vfm0Mi] [jar-文件] [manifest-文件] [-C 目录] 文件名 ...
选项:
-c 创建新的存档
-t 列出存档内容的列表
-x 展开存档中的命名的(或所有的〕文件
-u 更新已存在的存档
-v 生成详细输出到标准输出上
-f 指定存档文件名
-m 包含来自标明文件的标明信息
-0 只存储方式;未用zip压缩格式
-M 不产生所有项的清单(manifest〕文件
-i 为指定的jar文件产生索引信息
-C 改变到指定的目录,并且包含下列文件:
如果一个文件名是一个目录,它将被递归处理。
清单(manifest〕文件名和存档文件名都需要被指定,按'm' 和 'f'标志指定的相同顺序。
⑥ 如何将java文件打包成jar
1、右键文件,点击导出(Export);
2、选择Java文件夹下的JAR
file,点击next;
3、在JAR
file后面的
文本框
中选择导出的位置;
4、接下来全部点击next;
5、直到最后一个页面时点击finish;
6、完成。
⑦ java中class文件怎么打包成jar
jar的压缩使用:
可以使用命令指示符
指示的命令是jar -cvf jar文件名字.jar -C .\当前包的名字 .
实例1:
jar -cvf Manager.jar -C.\Jarfilemaking .
pause
有个问题是这个指令会将bat执行文件所在的所有东西全部打包成jar文件
而jar -cvf Manager.jar -C Jarfilemaking/ .
pause
则是只将bat文件所在包下的Jarfilemaking包下的所有东西打包成jar文件
⑧ 怎么把java文件打包成jar文件
jar
Picked up JAVA_TOOL_OPTIONS: -Duser.language=en
Usage: jar {ctxui}[vfmn0PMe] [jar-file] [manifest-file] [entry-point] [-C dir] files ...
Options:
-c create new archive
-t list table of contents for archive
-x extract named (or all) files from archive
-u update existing archive
-v generate verbose output on standard output
-f specify archive file name
-m include manifest information from specified manifest file
-e specify application entry point for stand-alone application
bundled into an executable jar file
-0 store only; use no ZIP compression
-P preserve leading '/' (absolute path) and ".." (parent directory) components from file names
-M do not create a manifest file for the entries
-i generate index information for the specified jar files
-C change to the specified directory and include the following file
If any file is a directory then it is processed recursively.
The manifest file name, the archive file name and the entry point name are
specified in the same order as the 'm', 'f' and 'e' flags.
Example 1: to archive two class files into an archive called classes.jar:
jar cvf classes.jar Foo.class Bar.class
Example 2: use an existing manifest file 'mymanifest' and archive all the
files in the foo/ directory into 'classes.jar':
jar cvfm classes.jar mymanifest -C foo/ .
⑨ 如何将多个Java源文件打包成jar包
你这问题 问的不太清楚
如果在Eclipse中对选中Java源文件进行打包的话,jar包内会变成对应的.class文件
说一下如何在eclipse中对多个源文件打成JAR包
在打开的项目中 按ctrl键 选择要打包的 java文件
选完后,点击鼠标右键-选择export
在弹出窗口的文本框中输入 jar,在搜索出来的选项中选择 JAR file .(如果需要打成可执行的jar需要选择Runnable JAR file,要确保选择的文件中有main方法)
点击[next] ,在弹出窗口中,指定JAR file 的路径和名称
最后点击 Finish .你的jar包就生成在指定目录了
⑩ 如何将一个java程序文件打包成jar
通过jar命令
jar命令的用法:
下面是jar命令的帮助说明:
用法:jar {ctxui}[vfm0Me] [jar-file] [manifest-file] [entry-point]
[-C dir] files ...
选项包括:
-c 创建新的归档文件
-t 列出归档目录
-x 解压缩已归档的指定(或所有)文件
-u 更新现有的归档文件
-v 在标准输出中生成详细输出
-f 指定归档文件名
-m 包含指定清单文件中的清单信息
-e 为捆绑到可执行 jar 文件的独立应用程序
指定应用程序入口点
-0 仅存储;不使用任何 ZIP 压缩
-M 不创建条目的清单文件
-i 为指定的 jar 文件生成索引信息
-C 更改为指定的目录并包含其中的文件
如果有任何目录文件,则对其进行递归处理。
清单文件名、归档文件名和入口点名的指定顺序
与 "m"、"f" 和 "e" 标志的指定顺序相同。
示例 1:将两个类文件归档到一个名为 classes.jar 的归档文件中:
jar cvf classes.jar Foo.class Bar.class
示例 2:使用现有的清单文件 "mymanifest" 并
将 foo/ 目录中的所有文件归档到 "classes.jar" 中:
jar cvfm classes.jar mymanifest -C foo/ .