top of page

Grupo de intereses compartidos

Público·69 miembros
Cameron Esparza
Cameron Esparza

Unix Command To Unzip Ear File

Although Java IDEs and numerous graphical tools make it easier than ever to view and manipulate the contents of Java archive (JAR, WAR, and EAR) files, there are times when I prefer to use the command-line jar command to accomplish these tasks. This is particularly true when I have to do something repeatedly or when I am doing it as part of a script. In this post, I look at use of the jar command to create, view, and manipulate Java archive files.

Unix Command To Unzip Ear File

JAR files will be used primarily in this post, but the commands I demonstrate on .jar files work consistently with .war and .ear files. It's also worth keeping in mind that the JAR format is based on the ZIP format and so the numerous tools available for working with ZIP files can be applied to JAR, WAR, and EAR files. It's also worth keeping in mind that the jar options tend to mirror tar's options.

For my examples, I want to jar up and work with some .class files. The next screen snapshot demonstrates compiling some Java source code files (.java files) into .class files. The actual source of these files is insignificant to this discussion and is not shown here. I have shown compiling these without an IDE to be consistent with using command-line tools in this post.

The "c" option provided to the jar command instructs it to create an archive. I like to use the "v" (verbose) and "f" (filename) options with all jar commands that I run so that the output will be verbose (to help see that something is happening and that it's the correct thing that's happening) and so that the applicable JAR/WAR/EAR filename can be provided as part of the command rather than input or output depending on standard input and standard output. In the case of creating a JAR file, the options "cvf" will create JAR file (c) with specified name (f) and print out verbose output (v) regarding this creation.

Listing (or viewing) the contents of a JAR, WAR, or EAR file is probably the function I perform most with thejar command. I typically use the options "t" (list contents of archive), "v" (verbose), and "f" (filename specified on command line) for this. The next screen snapshot demonstrates running jar tvf MyClasses.jar to view the contents of my generated JAR file.

I often only need to view or work with one or two files of the archive file. Although I could definitely extract all of them as shown in the last example and only edit those I need to edit, I prefer to extract only the files I need if the number of them is small. This is easily done with the same jar xvf command. By specifying the fully qualified files to extract explicitly after the archive file's name in the command, I can instruct to only extract those specific files. This is advantageous because I don't fill my directory up with files I don't care about and I don't need to worry about cleaning up as much when I'm done. The next screen snapshot demonstrates running jar xvf MyClasses.jar dustin/examples/jar/GrandParent.class to extract only that single class definition for GrandParent rather than extracting all the files in that JAR.

Previous examples have demonstrated providing the jar command with "c" to create an archive, "t" to list an archive's contents, and "x" to extract an archive's contents. Another commonly performed function is toupdate an existing archive's contents and this is accomplished with jar's "u" option. The next screen snapshot demonstrates creating a text file (in DOS with the copy con command) called tempfile.txt and then usingjar uvf MyClasses.jar tempfile.txt to update the MyClasses.jar and add tempfile.txt to that JAR.

If I want to update a file in an existing archive, I can extract that file using jar xvf, modify the file as desired, and place t back in the original JAR with the jar uvf command. The new file will overwrite the pre-existing one of the same name. This is simulated in the next screen snapshot.

The next screen snapshot demonstrates using 7-Zip (on Windows) to delete tempfile.txt fromMyClasses.jar by running the command 7z d MyClasses.jar tempfile.txt. Note that the same thing can be accomplished in Linux with zip -d MyClasses.jar tempfile.txt. Other ZIP-supporting tools have their own options.

In this post, I focused on the "CRUD" operations (Create/Read/Update/Delete) and extraction that can be performed from the command-line on Java archive files. I typically used the applicable "CRUD" operation command ("c", "t", "u") or extraction command ("x") used in conjunction with the common options "v" (verbose) and "f" (Java archive file name explicitly specified on command line). The jar command supports operations other than these such as "M" (controlling Manifest file creation) and "0" (controlling compression). I also did not demonstrate using "i" to generate index information for a Java archive.

The jar command is relatively easy to use and can be the quickest approach for creating, viewing, and modifying Java archive files contents in certain cases. Familiarity with this command-line tool can pay off from time to time for the Java developer, especially when working on a highly repetitive task or one that involves scripting. IDEs and tools (especially build tools) can help a lot with Java archive file manipulation, but sometimes the "overhead" of these is much greater than what is required when using jar from the command line.

The -p option to unzip instructs it to extract file2.war to its standard output, without anything else; then jar x reads file2.war from its standard input and extracts folder1/folder2/fileToExtract.txt.

When using sed it is more efficient to quit processing after having printed the last line than continue processing until the end of the file. This is especially important in the case of large files and printing lines at the beginning. In order to do so, the sed command above introduces the instruction 41q in order to stop processing after line 41 because in the example we are interested in lines 20-40 only. You will need to change the 41 to whatever the last line you are interested in is, plus one.

As many files as desired can be extracted from the JAR file in the same way. When the command doesn't specify which files to extract, the Jar tool extracts all files in the archive. For example, you can extract all the files in the TicTacToe archive by using this command:

In one of our several articles about the tar command, we showed you how to extract tar files to a specific or different directory in Linux. This short guide explains to you how to extract/unzip .zip archive files to a specific or different directory in Linux.

To create a .zip (packaged and compressed) file from the command line, you can run a similar command like the one below, The -r flag enables recursive reading of files directory structure.

To extract/unzip .zip archive files to specific or different directory from the command line, include the -d unzip command flag as shown below. We will use the same example above to demonstrate this.

HI As per my understanding, only export of Configuration file of all Deployed BW Process is not possible, but you can use the batch export commands to export all the ear files and configuration files of deployed BW Process, there you can filter for only for configuration files, hope this solution will work for your requirement.

I tried it once to deploy but got this error:No service configuration with name PartialBPM_V1.0.par. Please make sure contents in -deployconfig file matches -ear fileat

Otherwise,to build a Windows executable with pp from PAR::Packer,first install a Windows-based Perl distribution (for exampleStrawberry Perl or ActivePerl) following their instructions. Next, opena command prompt, aka a DOS window and install the PAR::Packer module.Finally, invoke the newly installed pp command with thecloc souce code to create an .exe file:C:> perl -MCPAN -e shellcpan> install PAR::Packercpan> exitC:> pp cloc-1.64.plA variation on the above is if you installed the portable versionof Strawberry Perl, you will need to run portableshell.batfirst to properly set up your environment. The Strawberry Perlderived executable on the SourceForge download area was createdwith the portable version on a Windows 7 computer.

Versions of cloc before v1.07 required an --extract-with= option to tell cloc howto expand an archive file. Beginning with v1.07 this is extraction isattempted automatically. At the moment the automatic extraction method worksreasonably well on Unix-type OS's for the following file types:.tar.gz,.tar.bz2,.tgz,.zip,.ear.Some of these extensions work on Windows if one has WinZip installedin the default location (C:\Program Files\WinZip\WinZip32.exe).Additionally, with newer versions of WinZip, the command line add-onis needed for correct operation; in this case one would invoke cloc withsomething like --extract-with="\"c:\Program Files\WinZip\wzunzip\" -e -o >FILE

In situations where the automatic extraction fails, one can try the --extract-with=option to count lines of code within tar files, Zip files, orother compressed archives for which one has an extraction tool.cloc takes the user-provided extraction command and expands the archiveto a temporary directory (created with File::Temp), counts the lines of code in the temporary directory,then removes that directory. While not especially helpful when dealingwith a single compressed archive (after all, if you're going to typethe extraction command anyway why not just manually expand the archive?)this option is handy for working with several archives at once.

The --sql switch tells cloc to generate output in the formof SQL table create and insert commands. The switch takes an argument of a file name to write these SQL statements into, or,if the argument is 1 (numeric one), streams output to STDOUT.Since the SQLite command line program, sqlite3, can readcommands from STDIN, we can dispense with storing SQL statements toa file and use --sql 1 to pipe data directly into theSQLite executable: 350c69d7ab

Acerca de

¡Bienvenido al grupo! Podrás conectarte con otros miembros, ...


bottom of page