jar


How to rename a jar file inside another jar file?


I have jar foo.jar which contains jar foo/config/baar-temp.jar.
What is the best method to rename baar-temp.jar to baar.jar?
Actually, jar format is based on zip and can be operated on as a file system using for example ZipFileSystemProvider available in Java7. That allows us to do a rather simple manipulation with the insides of one:
private void renameStuffInsideJar(String jarFilePath){
URI uri = URI.create("jar:file:"+jarFilePath);
try {
FileSystem jarFile = FileSystems.getFileSystem(uri)) {
Path pathInJarfile = jarFile.getPath("foo/config/baar-temp.jar");
Files.move(pathInZipfile,pathInZipfile.resolveSibling("baar.jar"));
} catch(IOException e){
//TODO
}
}
Alternatively, if it's not code you want, you could just open your jar file in your preferred archive manager like 7zip or WinRar and rename it using that.

Related Links

How to merge two jar files with same name but with different version in a project?
Combining projects into a single JAR
How to copy local jars in Maven when building JavaFX executable?
Using Phoenix minimal jar
Gradle, merge class from root and sub project
javafx jar builds fine but doesn't open
Liferay 6.2 add jars in Portal dependency
Create executable JAR from ANTLR source files
Can Weblogic deployment be configured to explode subordinate JARs as well?
How to include a Zip file inside a ShadowJar during Gradle build
Can't understand gradle jar task code that creates executable fat-jar
Logstash additional JARs
how to extract files form a jar file?
Why is my jar not loading?
Setting Jetty resourcebase to static file embedded in the same jar file
ClassLoader not recognizing programmatic jar file

Categories

HOME
sharepoint
sas
app-inventor
dynamics-crm
ubuntu-12.04
windows-store-apps
angular2-directives
gspread
jframe
hosts
flann
cs-cart
multiple-monitors
jquery-terminal
pyephem
zend-framework-mvc
google-api-java-client
cvs2svn
binutils
tampermonkey
fetch-api
pentaho-report-designer
winscp
vegan
android-vpn-service
honeysql
alchemy.js
dart-pub
distributed-transactions
crop
filepath
automator
fqdn
taskmanager
ideone
nstouchbar
struts-layout
butterknife
paas
communication-protocol
date-range
nsfetchedresultscontrolle
tomee
ruby-2.0
spoofing
instruments
multiple-file-upload
ng2-material
gemini
faraday
mongo-c-driver
gradle-release-plugin
post-processing
brackets-shell
windows-vista
affix
ipojo
risk-analysis
xjc
ffprobe
epl
hg-git
consensus
chaining
obfuscar
inputaccessoryview
microblaze
hidden-field
surrogate-key
bsp
delphi-xe3
modeshape
visual-studio-2003
google-closure-library
caliper
xmlslurper
rose-db-object
gdt
selectonemenu
curljs
smooth
drawtext
yajl
google-instant
rtsp-client
integer-promotion
method-signature

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App