I have a jar file Which displays an image file while running. Now i want to change the source code so that it displays a different image. How to do this process ?
Asked
Active
Viewed 1,583 times
-2
-
1post your source code,,, – sasikumar Mar 05 '16 at 11:29
-
It is jar file I cannot view class files I want to view the source file of this. – Sruthi Acg Mar 05 '16 at 11:30
-
1where you used that jar file in your code... – sasikumar Mar 05 '16 at 11:31
-
1If you don't have the sources, how would you change them? – Seelenvirtuose Mar 05 '16 at 11:32
-
I don't have source code is der any possibility to view the source from jar ? So that I can change it. – Sruthi Acg Mar 05 '16 at 11:34
2 Answers
0
Use Java Decompiler and decompile the jar file to java classes and edit the source, here take a look at this How do I "decompile" Java class files? or here try this online decompiler
-
I used java decompiler and it worked fine I am able to view the source code. Now I need to change one image in that jar and repack it. Can you please suggest me on how should I do it ? How do I replace my image file with the old one ? Even if I change the source I need to delete the image file which is packed with my jar. So please let me know what to do? – Sruthi Acg Mar 06 '16 at 14:10
-
@SruthiAcg you could go through the code and look for the image file name in the code and edit it to your image file name and then delete the image or just replace that image with your desired one – Mar 06 '16 at 14:17
-
I found out the place of the image file. But my question is can I do it in dis decompiler itself if so I don't have an option to delete or replace my image file – Sruthi Acg Mar 06 '16 at 14:28
-
@SruthiAcg yes but you will need to recompile it back, why dont you just get the source and do them in eclipse or something? have you seen the eclipse plugin in the jd webpage? take a look at that – Mar 06 '16 at 14:46
-
Ok thx fr ur suggestion I will try it out dat first and will post here – Sruthi Acg Mar 06 '16 at 16:08
0
Jar files are simply zip files with defined objects inside. There may be for example an META-INF folder or something like this.
Maybe you should simply take your jar, open it with some zip tool and replace the image resource inside with your image. This way you don't need to edit any sources.
If you encounter problems your zip tool might be the source of these problems. In this case you should try the program jar
for unpacking and repackaging your jar file. jar
is containded in any JDK.

blafasel
- 1,091
- 14
- 25
-
I tried replacing the image file just by unzipping it but I my old image s only displayed. I used WinZip . – Sruthi Acg Mar 05 '16 at 11:56
-
Be aware: a zip file can contain more than one resource with the same path and name. In this case Java simply takes the first one found. For this reason it may be neccessary to delete the old resource before adding the new one if you work on the zip file without unzipping it. – blafasel Mar 05 '16 at 12:00