Skip to content

Instantly share code, notes, and snippets.

@asavt92
Last active May 29, 2020 18:34
Show Gist options
  • Save asavt92/084f627d1bb05bc375f898a591279545 to your computer and use it in GitHub Desktop.
Save asavt92/084f627d1bb05bc375f898a591279545 to your computer and use it in GitHub Desktop.
JAVA jar editing
(IntellijIdea)
we have EsServer.jar archive and we plan to change EsServer.class file and rebuild jar.
1. Unzip JAR
unzip EsServer.jar -d ./out/
# or `jar xf ./EsServer.jar` to unzip to current dir
2. Decompile in IntellijIdea or by https://www.mikeleitz.com/blog/2018/8/9/decompile-java-classes-on-command-line `EsServer.class`
3. Update File EsServer.java
4. Compile EsServer.java
javac -classpath EsServer.jar ./EsServer.java
5. recreate archive
cd ./out && zip -r ../TestServer.jar *
# or u can use
# !!!! use -C flage
jar uf libs/EsServer.jar -C ./src/main/java/ org/sml/sber/EsServer.class
jar uf libs/EsServer.jar -C ./src/main/java/ org/sml/sber/EsServer$MyNode.class
Also:
1.
в project structure можно добавить project library (директорию или архив) - это пойдет в класспатх
либо смотрите на вкладке Dependencies у конкретного модуля.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment