Conversion of .class to jar and .class to exe

有些话、适合烂在心里 提交于 2019-12-03 01:15:21

Class files to jar files

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

file If any file is a directory then it is processed recursively. The manifest file name and the archive file name needs to be specified in the same order the 'm' and 'f' flags are specified.

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/ .

Convert jar files to .exe file

1)JSmooth .exe wrapper

2)JarToExe 1.8

3)Executor

4)Advanced Installer

Convert .class to .exe is discussed in length here

Nishant

You must have missed this. Please look into Java Archive (JAR) Files Guide.

And surely missed Real's How to for it Make a JAR executable There are multiple wrappers that do this work (converting Jar to exe, platform specific). You just need to search in StackOverflow for Jar exe

To convert (actually, package) .class files into .jar files, you use the jar tool. You can then generate a .exe file from the .jar using tools like Launch4j, JSmooth or several other packages (search the web for "jar exe").

If you are using Netbeans IDE, then creating .exe file from .class file won't take much time. In IDE, create a new project and put your java program in this project. Now follow these steps-

  1. Right click the project and choose properties.
  2. Choose run from left panel and enter the main class(in which main method is defined) in right panel.
  3. Again right click the project and choose add library. Select swing layout extensions. Click add library. 4.Now select clean and build from run menu in your IDE. Make sure that you have already set your this project as main project.
  4. Open the CMD and set the directory to your project. Go to "dist" > and type java -jar jarname.jar.
  5. Your program is running in cmd now.
  6. Open launch4j and provide the information required.
  7. Run and enjoy your application.

Create jar file using command line. Answer in http://download.oracle.com/javase/tutorial/deployment/jar/build.html

Class to exe. Answer in http://www.javacoffeebreak.com/faq/faq0042.html

Jar to exe. Answer in http://viralpatel.net/blogs/2009/02/convert-jar-to-exe-executable-jar-file-to-exe-converting.html

Converting exe to a jar file is possible. But involves reverse engineering to discover what is in the exe, extract and do whatever you want with it. In my opinion, is not worth at all.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!