LoginSignup
49
58

More than 5 years have passed since last update.

jarファイルの中身を見る・一部分抽出・一部分書き込み-覚書

Posted at

hoge.jarの中身を解凍せずに、中身を見たり抽出したりして、修正したあとに書き込みたい。
jar xvfで解凍するのが面倒な時に。

やり方

  • jarファイルの中身を見る
    jar tf [jarファイル名]

  • jarファイルの中身一部分を抽出
    jar -xvf [jarファイル名] [抽出するファイル名] [ディレクトリ名]

  • jarファイルの中身一部分書き込み
    jar -uf [jarファイル名] [書き込むファイル名] [ディレクトリ名]

実際の例

hoge.jarの中身
$ jar tf hoge.jar
META-INF/
META-INF/MANIFEST.MF
com/hoga/foo.class
com/hoga/bar.xml
piyo.xml
piyo.xmlの抽出
$ jar -xvf hoge.jar piyo.xml

※実行したディレクトリ配下に「piyo.xml」ファイルが置かれる。

piyo.xmlファイルの書き込み
$ jar -uf hoge.jar piyo.xml

com/hoga/bar.xmlを抽出したいときはディレクトリ名の指定をする。

bar.xmlの抽出
$ jar -xvf hoge.jar bar.xml com/hoga

※実行したディレクトリ配下に「com/hoga/bar.xml」が置かれる。

49
58
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
49
58