Reputation: 953
A coworker of mine wrote a class. His class uses my class. Rather than tell the JVM where my class lives every time his class is compiled, he packaged both classes into a jar file that I can run like so: java -jar hisclass.jar
Now I have decided to make changes to my class. Therefore, since my class was precompiled into his jar, his class (which I still need to use) uses my old class. My coworker left, and I don't know how he packaged everything into a jar file for me to use.
Now, when I try java -jar hisclass.jar
, when his class calls my class, it calls an old version of my class which produces an error, as that old version of my class no longer works correctly. Could anyone help me recompile his class into a jar or just update the one I have?
Upvotes: 1
Views: 8168
Reputation: 21
jar -uvf0 <YOUR_JAR_NAME>.jar io/some/package/service/TestService.class
jar -uvf0 <YOUR_JAR_NAME>.jar io/some/package/service/
Upvotes: 2
Reputation: 2479
In Eclipse i think it should be enough to export your code as jar file.
http://viralpatel.net/blogs/create-jar-file-in-java-eclipse/
So basically you get the old jar, extract, load as project in eclipse and export as jar file. And you're done.
Upvotes: 2
Reputation: 2803
Im not sure if you can get away with it or not, but you might want to just try compiling your class to a jar file, then opening his jar file up in some compression agent like WinRAR, and simply overwriting the old jar file contained in his jar file with your newly compiled version. A better way (if he class isnt obfuscated) would be to open his jar file in a Java IDE, and create a new project from it. Then reference the the project you created from his jar file in your project in the same IDE. This way, you can make changes to both in the same environment, and compiling the code after changes will be easier.
Upvotes: 0