Solved

Java and Linux, Can not unzip and zip a jar file

Posted on 2014-01-09
1
1,010 Views
Last Modified: 2014-01-10
I am using RHEL 6.5 and java 1.7

I test my jar file and it works successfully

I copy the jar file to a test directory and unzip it as follows:

cp test.jar /home/jar
mkdir /home/zipfile
cd /home/zipfile
unzip ../jar/test.jar

Open in new window


This unzips everything correctly

I then zip up the file as follows

cd /home/zipfile
zip -r /home/test.jar *.*
cd /home
cp test.jar /testdir
cd testdir

Open in new window


Now when I test the jar file I get the following error:

Error: Invalid or corrupt jarfile test.jar

Open in new window


What did I do wrong.  Was there a special flag I needed.  Any ideas ?

Thanks
0
Comment
Question by:Los Angeles1
1 Comment
 
LVL 14

Accepted Solution

by:
CPColin earned 500 total points
ID: 39769829
Try using * in your zip command, instead of *.*, which skips the META-INF directory. Java needs that directory in order to figure out what to do with the JAR file.
0

Featured Post

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How  can  i  resolve  HTTP Status 404 -? 8 46
JAVA API design with micro service cloud in mind 1 49
java imports not found 4 31
I NEED A "BARE" LINUX ... 9 57
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Google Drive is extremely cheap offsite storage, and it's even possible to get extra storage for free for two years.  You can use the free account 15GB, and if you have an Android device..when you install Google Drive for the first time it will give…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question