Updating .class file in jar
I want to update a .class file in a jar with a new one. What is the easiest way to do it, especially in the Eclipse IDE?
java eclipse jar
add a comment |
I want to update a .class file in a jar with a new one. What is the easiest way to do it, especially in the Eclipse IDE?
java eclipse jar
3
Have you triedjar --help
– Alexander Pogrebnyak
Nov 3 '09 at 12:58
add a comment |
I want to update a .class file in a jar with a new one. What is the easiest way to do it, especially in the Eclipse IDE?
java eclipse jar
I want to update a .class file in a jar with a new one. What is the easiest way to do it, especially in the Eclipse IDE?
java eclipse jar
java eclipse jar
edited Oct 13 '16 at 20:32
Einar Sundgren
2,46672951
2,46672951
asked Nov 3 '09 at 12:51
pengurupenguru
1,789113655
1,789113655
3
Have you triedjar --help
– Alexander Pogrebnyak
Nov 3 '09 at 12:58
add a comment |
3
Have you triedjar --help
– Alexander Pogrebnyak
Nov 3 '09 at 12:58
3
3
Have you tried
jar --help
– Alexander Pogrebnyak
Nov 3 '09 at 12:58
Have you tried
jar --help
– Alexander Pogrebnyak
Nov 3 '09 at 12:58
add a comment |
11 Answers
11
active
oldest
votes
This tutorial details how to update a jar file
jar uf jar-file input-file(s)
where 'u' means update.
3
In this command: The u option indicates that you want to update an existing JAR file. The f option indicates that the JAR file to update is specified on the command line. jar-file is the existing JAR file that's to be updated. input-file(s) is a space-delimited list of one or more files that you want to add to the Jar file.
– Nishantha
Jun 21 '13 at 6:43
1
I want to update a property file to a specific location, ideally there should be two parameterssource
anddestination
. For meinput-file(s)
, but where issource
?
– Shashi Ranjan
Jul 13 '17 at 7:40
@ShashiRanjan did you found the solution??
– Dinesh Phalwadiya
Dec 22 '17 at 4:56
2
@Dinesh I used "zip -u /var/opt/my-jar-with-dependencies.jar properties/my_app.properties". Basically "zip -u <source> <dest>", where dest is relative to the jar extract folder.
– Shashi Ranjan
Dec 22 '17 at 10:00
Thanks a lot @ShashiRanjan
– Dinesh Phalwadiya
Dec 22 '17 at 11:23
add a comment |
Do you want to do it automatically or manually? If manually, a JAR file is really just a ZIP file, so you should be able to open it with any ZIP reader. (You may need to change the extension first.) If you want to update the JAR file automatically via Eclipse, you may want to look into Ant support in Eclipse and look at the zip task.
add a comment |
Simply drag and drop your new class file to the JAR using 7-Zip or Winzip. You can even modify a JAR file that is included in a WAR file using the parent folder icon, and click Ok when 7zip detects that the inside file has been modified
Using WinZip, you have to open it by first starting WinZip, then drag the jar file into the WinZip window.
– awe
Apr 9 '10 at 6:17
1
7z on Windows does not respect upper/lower case, i.e. it would replace both CA.class and Ca.class
– Anton Duzenko
Apr 6 '16 at 11:04
add a comment |
Jar is an archive, you can replace a file in it by yourself in your favourite file manager (Total Commander for example).
add a comment |
- Use
jar -xvf
to extract the files to a directory. - Make your changes and replace the classes.
- Use
jar -cvf
to create a new jar file.
add a comment |
A JAR file is just a .zip in disguise. The zipped folder contains .class
files.
If you're on macOS:
- Rename the file to possess the '.zip' extension. e.g. myJar.jar -> myJar.zip.
- Decompress the '.zip' (double click on it). A new folder called 'myJar' will appear
- Find and replace the
.class
file with your new .class file. - Select all the contents of the folder 'myJar' and choose 'Compress x items'. DO NOT ZIP THE FOLDER ITSELF, ONLY ITS CONTENTS
Miscellaneous - Compiling a single .class file, with reference to a original jar, on macOS
- Make a file myClass.java, containing your code.
- Open terminal from Spotlight.
javac -classpath originalJar.jar myClass.java
This will create your compiled class called myClass.class.
From here, follow the steps above. You can also use Eclipse to compile it, simply reference the original jar by right clicking on the project, 'Build Path' -> 'Add External Archives'. From here you should be able to compile it as a jar, and use the zip technique above to retrieve the class from the jar.
add a comment |
1) you can extract the file into a folder called
jarname.jar
and then replace the file in the folder, handy if you are updating the class a lot while debugging
2) you can extract the jar replace the file then the jar it up again
3) Open the jar with 7 zip and drag and drop your new class in to copy over the old one
add a comment |
Editing properties/my_app.properties file inside jar:
"zip -u /var/opt/my-jar-with-dependencies.jar properties/my_app.properties"
. Basically "zip -u <source> <dest>"
, where dest is relative to the jar extract folder.
add a comment |
You can find source code of any .jar file online, import the same project in your IDE with basic setups. Make necessary changes in .java file and compile it for .class files.
Once compilation is done You need to extract the jar file, replace the old .class file with new one.
And use below command for reconstruct .jar file
Jar cf test.jar *
Note : I have done so many time this changes in our project, hope you will find it useful.
add a comment |
High-level steps:
Setup the environment
Use JD-GUI to peek into the JAR file
Unpack the JAR file
Modify the .class file with a Java Bytecode Editor
Update the modified classes into existing JAR file
Verify it with JD-GUI
Refer below link for detailed steps and methods to do it,
https://www.talksinfo.com/how-to-edit-class-file-from-a-jar/
add a comment |
An alternative is not to replace the .class file in the jar file. Instead put it into a new jar file and ensure that it appears earlier on your classpath than the original jar file.
Not sure I would recommend this for production software but for development it is quick and easy.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f1667153%2fupdating-class-file-in-jar%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
11 Answers
11
active
oldest
votes
11 Answers
11
active
oldest
votes
active
oldest
votes
active
oldest
votes
This tutorial details how to update a jar file
jar uf jar-file input-file(s)
where 'u' means update.
3
In this command: The u option indicates that you want to update an existing JAR file. The f option indicates that the JAR file to update is specified on the command line. jar-file is the existing JAR file that's to be updated. input-file(s) is a space-delimited list of one or more files that you want to add to the Jar file.
– Nishantha
Jun 21 '13 at 6:43
1
I want to update a property file to a specific location, ideally there should be two parameterssource
anddestination
. For meinput-file(s)
, but where issource
?
– Shashi Ranjan
Jul 13 '17 at 7:40
@ShashiRanjan did you found the solution??
– Dinesh Phalwadiya
Dec 22 '17 at 4:56
2
@Dinesh I used "zip -u /var/opt/my-jar-with-dependencies.jar properties/my_app.properties". Basically "zip -u <source> <dest>", where dest is relative to the jar extract folder.
– Shashi Ranjan
Dec 22 '17 at 10:00
Thanks a lot @ShashiRanjan
– Dinesh Phalwadiya
Dec 22 '17 at 11:23
add a comment |
This tutorial details how to update a jar file
jar uf jar-file input-file(s)
where 'u' means update.
3
In this command: The u option indicates that you want to update an existing JAR file. The f option indicates that the JAR file to update is specified on the command line. jar-file is the existing JAR file that's to be updated. input-file(s) is a space-delimited list of one or more files that you want to add to the Jar file.
– Nishantha
Jun 21 '13 at 6:43
1
I want to update a property file to a specific location, ideally there should be two parameterssource
anddestination
. For meinput-file(s)
, but where issource
?
– Shashi Ranjan
Jul 13 '17 at 7:40
@ShashiRanjan did you found the solution??
– Dinesh Phalwadiya
Dec 22 '17 at 4:56
2
@Dinesh I used "zip -u /var/opt/my-jar-with-dependencies.jar properties/my_app.properties". Basically "zip -u <source> <dest>", where dest is relative to the jar extract folder.
– Shashi Ranjan
Dec 22 '17 at 10:00
Thanks a lot @ShashiRanjan
– Dinesh Phalwadiya
Dec 22 '17 at 11:23
add a comment |
This tutorial details how to update a jar file
jar uf jar-file input-file(s)
where 'u' means update.
This tutorial details how to update a jar file
jar uf jar-file input-file(s)
where 'u' means update.
answered Nov 3 '09 at 13:14
Brian AgnewBrian Agnew
229k32281395
229k32281395
3
In this command: The u option indicates that you want to update an existing JAR file. The f option indicates that the JAR file to update is specified on the command line. jar-file is the existing JAR file that's to be updated. input-file(s) is a space-delimited list of one or more files that you want to add to the Jar file.
– Nishantha
Jun 21 '13 at 6:43
1
I want to update a property file to a specific location, ideally there should be two parameterssource
anddestination
. For meinput-file(s)
, but where issource
?
– Shashi Ranjan
Jul 13 '17 at 7:40
@ShashiRanjan did you found the solution??
– Dinesh Phalwadiya
Dec 22 '17 at 4:56
2
@Dinesh I used "zip -u /var/opt/my-jar-with-dependencies.jar properties/my_app.properties". Basically "zip -u <source> <dest>", where dest is relative to the jar extract folder.
– Shashi Ranjan
Dec 22 '17 at 10:00
Thanks a lot @ShashiRanjan
– Dinesh Phalwadiya
Dec 22 '17 at 11:23
add a comment |
3
In this command: The u option indicates that you want to update an existing JAR file. The f option indicates that the JAR file to update is specified on the command line. jar-file is the existing JAR file that's to be updated. input-file(s) is a space-delimited list of one or more files that you want to add to the Jar file.
– Nishantha
Jun 21 '13 at 6:43
1
I want to update a property file to a specific location, ideally there should be two parameterssource
anddestination
. For meinput-file(s)
, but where issource
?
– Shashi Ranjan
Jul 13 '17 at 7:40
@ShashiRanjan did you found the solution??
– Dinesh Phalwadiya
Dec 22 '17 at 4:56
2
@Dinesh I used "zip -u /var/opt/my-jar-with-dependencies.jar properties/my_app.properties". Basically "zip -u <source> <dest>", where dest is relative to the jar extract folder.
– Shashi Ranjan
Dec 22 '17 at 10:00
Thanks a lot @ShashiRanjan
– Dinesh Phalwadiya
Dec 22 '17 at 11:23
3
3
In this command: The u option indicates that you want to update an existing JAR file. The f option indicates that the JAR file to update is specified on the command line. jar-file is the existing JAR file that's to be updated. input-file(s) is a space-delimited list of one or more files that you want to add to the Jar file.
– Nishantha
Jun 21 '13 at 6:43
In this command: The u option indicates that you want to update an existing JAR file. The f option indicates that the JAR file to update is specified on the command line. jar-file is the existing JAR file that's to be updated. input-file(s) is a space-delimited list of one or more files that you want to add to the Jar file.
– Nishantha
Jun 21 '13 at 6:43
1
1
I want to update a property file to a specific location, ideally there should be two parameters
source
and destination
. For me input-file(s)
, but where is source
?– Shashi Ranjan
Jul 13 '17 at 7:40
I want to update a property file to a specific location, ideally there should be two parameters
source
and destination
. For me input-file(s)
, but where is source
?– Shashi Ranjan
Jul 13 '17 at 7:40
@ShashiRanjan did you found the solution??
– Dinesh Phalwadiya
Dec 22 '17 at 4:56
@ShashiRanjan did you found the solution??
– Dinesh Phalwadiya
Dec 22 '17 at 4:56
2
2
@Dinesh I used "zip -u /var/opt/my-jar-with-dependencies.jar properties/my_app.properties". Basically "zip -u <source> <dest>", where dest is relative to the jar extract folder.
– Shashi Ranjan
Dec 22 '17 at 10:00
@Dinesh I used "zip -u /var/opt/my-jar-with-dependencies.jar properties/my_app.properties". Basically "zip -u <source> <dest>", where dest is relative to the jar extract folder.
– Shashi Ranjan
Dec 22 '17 at 10:00
Thanks a lot @ShashiRanjan
– Dinesh Phalwadiya
Dec 22 '17 at 11:23
Thanks a lot @ShashiRanjan
– Dinesh Phalwadiya
Dec 22 '17 at 11:23
add a comment |
Do you want to do it automatically or manually? If manually, a JAR file is really just a ZIP file, so you should be able to open it with any ZIP reader. (You may need to change the extension first.) If you want to update the JAR file automatically via Eclipse, you may want to look into Ant support in Eclipse and look at the zip task.
add a comment |
Do you want to do it automatically or manually? If manually, a JAR file is really just a ZIP file, so you should be able to open it with any ZIP reader. (You may need to change the extension first.) If you want to update the JAR file automatically via Eclipse, you may want to look into Ant support in Eclipse and look at the zip task.
add a comment |
Do you want to do it automatically or manually? If manually, a JAR file is really just a ZIP file, so you should be able to open it with any ZIP reader. (You may need to change the extension first.) If you want to update the JAR file automatically via Eclipse, you may want to look into Ant support in Eclipse and look at the zip task.
Do you want to do it automatically or manually? If manually, a JAR file is really just a ZIP file, so you should be able to open it with any ZIP reader. (You may need to change the extension first.) If you want to update the JAR file automatically via Eclipse, you may want to look into Ant support in Eclipse and look at the zip task.
edited Jan 23 '11 at 23:53
martin clayton
66k18187181
66k18187181
answered Nov 3 '09 at 12:54
JasCavJasCav
25.9k1897152
25.9k1897152
add a comment |
add a comment |
Simply drag and drop your new class file to the JAR using 7-Zip or Winzip. You can even modify a JAR file that is included in a WAR file using the parent folder icon, and click Ok when 7zip detects that the inside file has been modified
Using WinZip, you have to open it by first starting WinZip, then drag the jar file into the WinZip window.
– awe
Apr 9 '10 at 6:17
1
7z on Windows does not respect upper/lower case, i.e. it would replace both CA.class and Ca.class
– Anton Duzenko
Apr 6 '16 at 11:04
add a comment |
Simply drag and drop your new class file to the JAR using 7-Zip or Winzip. You can even modify a JAR file that is included in a WAR file using the parent folder icon, and click Ok when 7zip detects that the inside file has been modified
Using WinZip, you have to open it by first starting WinZip, then drag the jar file into the WinZip window.
– awe
Apr 9 '10 at 6:17
1
7z on Windows does not respect upper/lower case, i.e. it would replace both CA.class and Ca.class
– Anton Duzenko
Apr 6 '16 at 11:04
add a comment |
Simply drag and drop your new class file to the JAR using 7-Zip or Winzip. You can even modify a JAR file that is included in a WAR file using the parent folder icon, and click Ok when 7zip detects that the inside file has been modified
Simply drag and drop your new class file to the JAR using 7-Zip or Winzip. You can even modify a JAR file that is included in a WAR file using the parent folder icon, and click Ok when 7zip detects that the inside file has been modified
answered Nov 3 '09 at 13:47
LastnicoLastnico
1,3011013
1,3011013
Using WinZip, you have to open it by first starting WinZip, then drag the jar file into the WinZip window.
– awe
Apr 9 '10 at 6:17
1
7z on Windows does not respect upper/lower case, i.e. it would replace both CA.class and Ca.class
– Anton Duzenko
Apr 6 '16 at 11:04
add a comment |
Using WinZip, you have to open it by first starting WinZip, then drag the jar file into the WinZip window.
– awe
Apr 9 '10 at 6:17
1
7z on Windows does not respect upper/lower case, i.e. it would replace both CA.class and Ca.class
– Anton Duzenko
Apr 6 '16 at 11:04
Using WinZip, you have to open it by first starting WinZip, then drag the jar file into the WinZip window.
– awe
Apr 9 '10 at 6:17
Using WinZip, you have to open it by first starting WinZip, then drag the jar file into the WinZip window.
– awe
Apr 9 '10 at 6:17
1
1
7z on Windows does not respect upper/lower case, i.e. it would replace both CA.class and Ca.class
– Anton Duzenko
Apr 6 '16 at 11:04
7z on Windows does not respect upper/lower case, i.e. it would replace both CA.class and Ca.class
– Anton Duzenko
Apr 6 '16 at 11:04
add a comment |
Jar is an archive, you can replace a file in it by yourself in your favourite file manager (Total Commander for example).
add a comment |
Jar is an archive, you can replace a file in it by yourself in your favourite file manager (Total Commander for example).
add a comment |
Jar is an archive, you can replace a file in it by yourself in your favourite file manager (Total Commander for example).
Jar is an archive, you can replace a file in it by yourself in your favourite file manager (Total Commander for example).
answered Nov 3 '09 at 12:55
silentsilent
2,9801729
2,9801729
add a comment |
add a comment |
- Use
jar -xvf
to extract the files to a directory. - Make your changes and replace the classes.
- Use
jar -cvf
to create a new jar file.
add a comment |
- Use
jar -xvf
to extract the files to a directory. - Make your changes and replace the classes.
- Use
jar -cvf
to create a new jar file.
add a comment |
- Use
jar -xvf
to extract the files to a directory. - Make your changes and replace the classes.
- Use
jar -cvf
to create a new jar file.
- Use
jar -xvf
to extract the files to a directory. - Make your changes and replace the classes.
- Use
jar -cvf
to create a new jar file.
answered Oct 21 '14 at 19:23
James LimJames Lim
10.7k33057
10.7k33057
add a comment |
add a comment |
A JAR file is just a .zip in disguise. The zipped folder contains .class
files.
If you're on macOS:
- Rename the file to possess the '.zip' extension. e.g. myJar.jar -> myJar.zip.
- Decompress the '.zip' (double click on it). A new folder called 'myJar' will appear
- Find and replace the
.class
file with your new .class file. - Select all the contents of the folder 'myJar' and choose 'Compress x items'. DO NOT ZIP THE FOLDER ITSELF, ONLY ITS CONTENTS
Miscellaneous - Compiling a single .class file, with reference to a original jar, on macOS
- Make a file myClass.java, containing your code.
- Open terminal from Spotlight.
javac -classpath originalJar.jar myClass.java
This will create your compiled class called myClass.class.
From here, follow the steps above. You can also use Eclipse to compile it, simply reference the original jar by right clicking on the project, 'Build Path' -> 'Add External Archives'. From here you should be able to compile it as a jar, and use the zip technique above to retrieve the class from the jar.
add a comment |
A JAR file is just a .zip in disguise. The zipped folder contains .class
files.
If you're on macOS:
- Rename the file to possess the '.zip' extension. e.g. myJar.jar -> myJar.zip.
- Decompress the '.zip' (double click on it). A new folder called 'myJar' will appear
- Find and replace the
.class
file with your new .class file. - Select all the contents of the folder 'myJar' and choose 'Compress x items'. DO NOT ZIP THE FOLDER ITSELF, ONLY ITS CONTENTS
Miscellaneous - Compiling a single .class file, with reference to a original jar, on macOS
- Make a file myClass.java, containing your code.
- Open terminal from Spotlight.
javac -classpath originalJar.jar myClass.java
This will create your compiled class called myClass.class.
From here, follow the steps above. You can also use Eclipse to compile it, simply reference the original jar by right clicking on the project, 'Build Path' -> 'Add External Archives'. From here you should be able to compile it as a jar, and use the zip technique above to retrieve the class from the jar.
add a comment |
A JAR file is just a .zip in disguise. The zipped folder contains .class
files.
If you're on macOS:
- Rename the file to possess the '.zip' extension. e.g. myJar.jar -> myJar.zip.
- Decompress the '.zip' (double click on it). A new folder called 'myJar' will appear
- Find and replace the
.class
file with your new .class file. - Select all the contents of the folder 'myJar' and choose 'Compress x items'. DO NOT ZIP THE FOLDER ITSELF, ONLY ITS CONTENTS
Miscellaneous - Compiling a single .class file, with reference to a original jar, on macOS
- Make a file myClass.java, containing your code.
- Open terminal from Spotlight.
javac -classpath originalJar.jar myClass.java
This will create your compiled class called myClass.class.
From here, follow the steps above. You can also use Eclipse to compile it, simply reference the original jar by right clicking on the project, 'Build Path' -> 'Add External Archives'. From here you should be able to compile it as a jar, and use the zip technique above to retrieve the class from the jar.
A JAR file is just a .zip in disguise. The zipped folder contains .class
files.
If you're on macOS:
- Rename the file to possess the '.zip' extension. e.g. myJar.jar -> myJar.zip.
- Decompress the '.zip' (double click on it). A new folder called 'myJar' will appear
- Find and replace the
.class
file with your new .class file. - Select all the contents of the folder 'myJar' and choose 'Compress x items'. DO NOT ZIP THE FOLDER ITSELF, ONLY ITS CONTENTS
Miscellaneous - Compiling a single .class file, with reference to a original jar, on macOS
- Make a file myClass.java, containing your code.
- Open terminal from Spotlight.
javac -classpath originalJar.jar myClass.java
This will create your compiled class called myClass.class.
From here, follow the steps above. You can also use Eclipse to compile it, simply reference the original jar by right clicking on the project, 'Build Path' -> 'Add External Archives'. From here you should be able to compile it as a jar, and use the zip technique above to retrieve the class from the jar.
edited Jun 4 '17 at 5:00
answered Sep 12 '16 at 20:42
Toby MellorToby Mellor
5,77851946
5,77851946
add a comment |
add a comment |
1) you can extract the file into a folder called
jarname.jar
and then replace the file in the folder, handy if you are updating the class a lot while debugging
2) you can extract the jar replace the file then the jar it up again
3) Open the jar with 7 zip and drag and drop your new class in to copy over the old one
add a comment |
1) you can extract the file into a folder called
jarname.jar
and then replace the file in the folder, handy if you are updating the class a lot while debugging
2) you can extract the jar replace the file then the jar it up again
3) Open the jar with 7 zip and drag and drop your new class in to copy over the old one
add a comment |
1) you can extract the file into a folder called
jarname.jar
and then replace the file in the folder, handy if you are updating the class a lot while debugging
2) you can extract the jar replace the file then the jar it up again
3) Open the jar with 7 zip and drag and drop your new class in to copy over the old one
1) you can extract the file into a folder called
jarname.jar
and then replace the file in the folder, handy if you are updating the class a lot while debugging
2) you can extract the jar replace the file then the jar it up again
3) Open the jar with 7 zip and drag and drop your new class in to copy over the old one
answered Nov 3 '09 at 13:19
Craig AngusCraig Angus
11.4k155161
11.4k155161
add a comment |
add a comment |
Editing properties/my_app.properties file inside jar:
"zip -u /var/opt/my-jar-with-dependencies.jar properties/my_app.properties"
. Basically "zip -u <source> <dest>"
, where dest is relative to the jar extract folder.
add a comment |
Editing properties/my_app.properties file inside jar:
"zip -u /var/opt/my-jar-with-dependencies.jar properties/my_app.properties"
. Basically "zip -u <source> <dest>"
, where dest is relative to the jar extract folder.
add a comment |
Editing properties/my_app.properties file inside jar:
"zip -u /var/opt/my-jar-with-dependencies.jar properties/my_app.properties"
. Basically "zip -u <source> <dest>"
, where dest is relative to the jar extract folder.
Editing properties/my_app.properties file inside jar:
"zip -u /var/opt/my-jar-with-dependencies.jar properties/my_app.properties"
. Basically "zip -u <source> <dest>"
, where dest is relative to the jar extract folder.
answered Dec 22 '17 at 10:03
Shashi RanjanShashi Ranjan
69221226
69221226
add a comment |
add a comment |
You can find source code of any .jar file online, import the same project in your IDE with basic setups. Make necessary changes in .java file and compile it for .class files.
Once compilation is done You need to extract the jar file, replace the old .class file with new one.
And use below command for reconstruct .jar file
Jar cf test.jar *
Note : I have done so many time this changes in our project, hope you will find it useful.
add a comment |
You can find source code of any .jar file online, import the same project in your IDE with basic setups. Make necessary changes in .java file and compile it for .class files.
Once compilation is done You need to extract the jar file, replace the old .class file with new one.
And use below command for reconstruct .jar file
Jar cf test.jar *
Note : I have done so many time this changes in our project, hope you will find it useful.
add a comment |
You can find source code of any .jar file online, import the same project in your IDE with basic setups. Make necessary changes in .java file and compile it for .class files.
Once compilation is done You need to extract the jar file, replace the old .class file with new one.
And use below command for reconstruct .jar file
Jar cf test.jar *
Note : I have done so many time this changes in our project, hope you will find it useful.
You can find source code of any .jar file online, import the same project in your IDE with basic setups. Make necessary changes in .java file and compile it for .class files.
Once compilation is done You need to extract the jar file, replace the old .class file with new one.
And use below command for reconstruct .jar file
Jar cf test.jar *
Note : I have done so many time this changes in our project, hope you will find it useful.
answered Mar 22 '18 at 10:07
harihari
337
337
add a comment |
add a comment |
High-level steps:
Setup the environment
Use JD-GUI to peek into the JAR file
Unpack the JAR file
Modify the .class file with a Java Bytecode Editor
Update the modified classes into existing JAR file
Verify it with JD-GUI
Refer below link for detailed steps and methods to do it,
https://www.talksinfo.com/how-to-edit-class-file-from-a-jar/
add a comment |
High-level steps:
Setup the environment
Use JD-GUI to peek into the JAR file
Unpack the JAR file
Modify the .class file with a Java Bytecode Editor
Update the modified classes into existing JAR file
Verify it with JD-GUI
Refer below link for detailed steps and methods to do it,
https://www.talksinfo.com/how-to-edit-class-file-from-a-jar/
add a comment |
High-level steps:
Setup the environment
Use JD-GUI to peek into the JAR file
Unpack the JAR file
Modify the .class file with a Java Bytecode Editor
Update the modified classes into existing JAR file
Verify it with JD-GUI
Refer below link for detailed steps and methods to do it,
https://www.talksinfo.com/how-to-edit-class-file-from-a-jar/
High-level steps:
Setup the environment
Use JD-GUI to peek into the JAR file
Unpack the JAR file
Modify the .class file with a Java Bytecode Editor
Update the modified classes into existing JAR file
Verify it with JD-GUI
Refer below link for detailed steps and methods to do it,
https://www.talksinfo.com/how-to-edit-class-file-from-a-jar/
answered Nov 25 '18 at 20:47
user2266614user2266614
13
13
add a comment |
add a comment |
An alternative is not to replace the .class file in the jar file. Instead put it into a new jar file and ensure that it appears earlier on your classpath than the original jar file.
Not sure I would recommend this for production software but for development it is quick and easy.
add a comment |
An alternative is not to replace the .class file in the jar file. Instead put it into a new jar file and ensure that it appears earlier on your classpath than the original jar file.
Not sure I would recommend this for production software but for development it is quick and easy.
add a comment |
An alternative is not to replace the .class file in the jar file. Instead put it into a new jar file and ensure that it appears earlier on your classpath than the original jar file.
Not sure I would recommend this for production software but for development it is quick and easy.
An alternative is not to replace the .class file in the jar file. Instead put it into a new jar file and ensure that it appears earlier on your classpath than the original jar file.
Not sure I would recommend this for production software but for development it is quick and easy.
answered Nov 3 '09 at 13:56
Dave JeffersonDave Jefferson
1262
1262
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f1667153%2fupdating-class-file-in-jar%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
3
Have you tried
jar --help
– Alexander Pogrebnyak
Nov 3 '09 at 12:58