SaltyDawg
asked on
Add Class file to existing Jar File
I have an existing Jar File:
chop_saw.jar
With the following directories and files:
Ebtron
-mechanicalFunctions.class
-EbtronUser.class
-ebtronModel.class
-chopSaw.class
-chopSaw$Display.class
-chopSaw$3.class
-chopSaw$2.class
-chopSaw$1.class
META-INF
-MANIFEST.MF
"Manifest-Version: 1.0
Ant-Version: Apache Ant 1.6.2
Created-By: 1.5.0_04-b05 (Sun Microsystems Inc.)
Main-Class: Ebtron.chopSaw
X-COMMENT: Main-Class will be added automatically by build"
Now my question, is it possible to replace one of the class files? I updated "mechanicalFunctions.class ". Can I add the new "mechanicalFunctions.class " file and replace the existing one without changing any of the other files. Add would the jar file still work as a clickable executable as before?
Thankx
chop_saw.jar
With the following directories and files:
Ebtron
-mechanicalFunctions.class
-EbtronUser.class
-ebtronModel.class
-chopSaw.class
-chopSaw$Display.class
-chopSaw$3.class
-chopSaw$2.class
-chopSaw$1.class
META-INF
-MANIFEST.MF
"Manifest-Version: 1.0
Ant-Version: Apache Ant 1.6.2
Created-By: 1.5.0_04-b05 (Sun Microsystems Inc.)
Main-Class: Ebtron.chopSaw
X-COMMENT: Main-Class will be added automatically by build"
Now my question, is it possible to replace one of the class files? I updated "mechanicalFunctions.class
Thankx
With Linux, you would do this:
unzip chop_saw.jar
cp mechanicalFunctions.class Ebtron
zip chop_saw.jar Ebtron
ASKER
If I unzip the file, then replace the class, how do I create a new jar file? Is there an application that creates one. I cannot do it using WinZip or WinRar.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
How do I run jar.exe, whenever I try to open it, it closes immediatley
Command for updating a jar is..
jar -uvf chop_saw.jar Ebtron/mechanicalFunctions .class
jar -uvf chop_saw.jar Ebtron/mechanicalFunctions
>> How do I run jar.exe, whenever I try to open it, it closes immediatley
How did you make the jar.. ?
How did you make the jar.. ?
ASKER
The jar was originally created by someone else
ASKER
I used "jar -uvf chop_saw.jar Ebtron/mechanicalFunctions .class" but got an error
Exception in thread "main" java.lang.NoClassDefFoundE rror: jar
Exception in thread "main" java.lang.NoClassDefFoundE
ASKER
I used it in the command prompt is that right?
Try giving complete path to jar
C:\java\bin\jar -uvf chop_saw.jar Ebtron/mechanicalFunctions .class
C:\java\bin\jar -uvf chop_saw.jar Ebtron/mechanicalFunctions
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
So:
Unzip the jar in a folder.
Replace the .class file you want
Zip the folder to a .jar file
I already did that.