I have a sample.ear file and I want to replace a particular file inside sample.ear.
consider ear file sample.ear which content com1/test1/file1.sh and com2/file2.sh
here I want to replace file1.sh with updated file file1.sh using unix.
I am using jar command but i am not able to replace the file in subdirectories
Thanks
Use:
jar -xf sample.ear com1/test1/file1.sh
to extract file.sh. Once you are done modifying this com1/test1/file1.sh file use:
jar -uf sample.ear com1/test1/file1.sh
to update the archived ear with the modified file.
Use jar --help for detailed help.
Related
I want to convert folder to jar,
is there any command for cmd in window or good online converter to convert it?
Thanks in Advance.
a jar file is for a java program, if you need to compress a folder into a single file, try zip. You should be able to do it in windows.
https://support.microsoft.com/en-us/help/14200/windows-compress-uncompress-zip-files
You can install 7zip if you need a command line client.
I want to convert my jar file to eclipse project, so that i can make changes in the existing code. Can anyone help me with this. I tried extracting jar using jar xf myjar.jar command through command prompt but it gave me only .class files and i want to generate .java files of my project through it.
I have one JAR named as abc.jar with 15 class files. In JAR file I need to modify xyz.class, so I decompiled to xyz.java and modified it.
How can I update that JAR with the modified Java file? While trying to create (compile) the JAR file I am getting errors.
You can add your newly compiled class to the jar and overwrite the old one, here is how to add xyz.class and xyz.java to the jar :
jar uf abc.jar xyz.class xyz.java
See here for more about updating a jar file.
Or simply you can use any archiving tool, like winrar to open and add files to the jar.
Compile the xyz.java and replace the xyz.class file directly in jar without building the jar again, if the single class has been modified.
I wanted to convert .java file to executable jar file,i did so in the command prompt. But everytime i double click (open) it nothing happens.
jar cf Calculate.jar Calculator.java
This is what i typed in the cmd. How to get an executable file? I use windows
That's not how it works, that way you are creating a jar archive with that .java file in it.
If you want to create the jar manually (if you want to do it one time, instead of using a build tool like ant or maven, it could have some educational value), you have to compile your .java file to a .class with javac, add it to the jar and then modify the META-INF/MANIFEST.MF manifest file to specify Calculator as value for the Main-Class attribute.
See this old guide from Sun.
How to identify the corrupted jar files in my classpath using jar commands.
Will -xvf help in sorting out corrupted jars?
Please help.
I think you would need to look at each jar file individually and allow the jar command to tell when an archive is corrupt. You can use the list command for this:
$ jar tf <jarfile>
Alternatively I guess you could just run java itself, with your desired classpath, and hope that is declares which jar files are corrupt.