.class文件转换为jar和.class文件转换为exe

12

如何使用cmd将class文件转换为jar文件?

  • 如何将class文件转换为exe文件?
  • 如何将jar文件转换为exe文件?

能否将exe文件转换为jar文件?


1
你是想本地编译Java代码,还是只是在类文件/ jar周围创建一个包装器? - Michael Berry
5个回答

24

将类文件转换为jar文件

Usage: jar {ctxu}[vfm0M][jar-file]

[manifest-file] [-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

 -0  store only; use no ZIP compression

 -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
如果任何文件是目录,则会进行递归处理。清单文件名和存档文件名需要按照'm'和'f'标志指定的相同顺序进行指定。

Example 1: to archive two class files into an archive called classes.jar:

`jar cvf classes.jar Foo.class Bar.class` 

示例2:使用现有清单文件'mymanifest'和归档文件

将foo/目录中的所有文件归档到'classes.jar'中:

jar cvfm classes.jar mymanifest -C foo/ .

将jar文件转换为.exe文件
1) JSmooth .exe包装器 2) JarToExe 1.8 3) Executor 4) 高级安装程序 在这里详细讨论了将.class转换为.exe

3

2
将.class文件转换(实际上是打包)为.jar文件,您可以使用jar工具。然后,您可以使用像Launch4jJSmooth或其他几个软件包(在网络上搜索“jar exe”)的工具从.jar生成.exe文件。

1
如果您正在使用Netbeans IDE,则从.class文件创建.exe文件不需要太多时间。在IDE中,创建一个新项目并将Java程序放入该项目中。现在按照以下步骤操作:
  1. 右键单击项目并选择属性。
  2. 从左侧面板选择运行,并在右侧面板中输入主类(其中定义了主方法)。
  3. 再次右键单击项目并选择添加库。 选择Swing布局扩展。 点击添加库。 4.现在从IDE的运行菜单中选择清理和构建。 确保您已经将此项目设置为主项目。
  4. 打开CMD并将目录设置为您的项目。 转到“dist”,>并键入java -jar jarname.jar。
  5. 您的程序现在在cmd中运行。
  6. 打开Launch4j并提供所需的信息。
  7. 运行并享受您的应用程序。

0

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接