g46905
asked on
command to replace a .class file in my jar?
I have my Test.jar file. I would like to replace a .class file in com.sendMail package which is in my Test.jar file. how can I do this using command line argument in my unix environment? Please help.
You can't - you need to create a new jar
Oh wait
jar uf yourjar.jar NewClass.class
would replace the one of the same name
jar uf yourjar.jar NewClass.class
would replace the one of the same name
ASKER
does it need to be jar uf yourjar.jar com.sendMail.NewClass.clas s ( am I supposed mention the package name along with the class name ) Please suggest.
Yes you would need to specify the full path
jar uf yourjar.jar com/sendMail/NewClass.clas s
jar uf yourjar.jar com/sendMail/NewClass.clas
ASKER
Below is what I tried and for some reason, it doesn't work...can you help me with this..
jar uf Test.jar com/sendMail/NewClass.clas s ( Result = no such file or directory )
file name = testMail
replace with = com/sendMail/testMail
This is what I did...
jar uf Test.jar com/sendMail/testMail <<----------------- am I supposed to specify both old and the new file name
If yes, can you provide an example?
Thanks
jar uf Test.jar com/sendMail/NewClass.clas
file name = testMail
replace with = com/sendMail/testMail
This is what I did...
jar uf Test.jar com/sendMail/testMail <<----------------- am I supposed to specify both old and the new file name
If yes, can you provide an example?
Thanks
you need to be in the directory that contains the com directory
You don't actually. You can do
ar uf Test.jar -C DirWithComInIt com/sendMail/testMail
ar uf Test.jar -C DirWithComInIt com/sendMail/testMail
Missing 'j' there of course. The file to be replaced needs to be exactly the same name and path of course
ASKER
Ok.......
I am getting confused here..
I believe we need to specify the new file name ( newFile.class ) and the existing file name ( com/test/newFile.class ) which needs to be replaced in the command line. If we dont do that....how will the executable know which file needs to be what file. Am I missing something...please correct me if I am wrong
I am getting confused here..
I believe we need to specify the new file name ( newFile.class ) and the existing file name ( com/test/newFile.class ) which needs to be replaced in the command line. If we dont do that....how will the executable know which file needs to be what file. Am I missing something...please correct me if I am wrong
ASKER
Oops ...it is 'jar' and it is a typo when I posted you...
You can replace an entry with a different one (different in the sense of a different path in the entry)
>>You can replace an entry
Should have been CAN'T !!
Should have been CAN'T !!
The API documents explain that
ASKER
I hope I am not confusing you..
I am in the /bin directory where I have my Test.jar file and my modified .class file ( For example: testMail.class )
I would like to replace my modified file ( testMail.class ) with com/sendMail/testMail in my Test.jar file.Now, Can you show me the exact command that I need to use?
I am in the /bin directory where I have my Test.jar file and my modified .class file ( For example: testMail.class )
I would like to replace my modified file ( testMail.class ) with com/sendMail/testMail in my Test.jar file.Now, Can you show me the exact command that I need to use?
your class file should be in the correct directory structure
First of all, can you post the result of the following
jar tf Test.jar
jar tf Test.jar
ASKER
below is the result...
com/sendMail/BooleanObject .class
com/sendMail/CommentEOLIte rator.clas s
com/sendMail/CompareVersio ns.class
com/sendMail/testMail.clas s
Please let me know if you have any questions.
com/sendMail/BooleanObject
com/sendMail/CommentEOLIte
com/sendMail/CompareVersio
com/sendMail/testMail.clas
Please let me know if you have any questions.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
What is X and Y
Any directory
:-)