• Post Reply Bookmark Topic Watch Topic
  • New Topic

Exception in thread "main" java.util.zip.ZipException  RSS feed

 
Scarbez Seeker
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I developed an application and packed it as a jar file. I am trying to execute and get (ommitted sensitive data for security purposes):
C:\>java -DOMMITTED_ARG -jar package.class_containing_main start "C:\projects\current_project\build\XML"
Exception in thread "main" java.util.zip.ZipException: El sistema no puede halla
r el archivo especificado
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.<init>(Unknown Source)
at java.util.jar.JarFile.<init>(Unknown Source)
at java.util.jar.JarFile.<init>(Unknown Source)
The start option is because I am using the Java Service Wrapper. The other argument is a path to some XML files. I thought there was a problem unjarring and unzipping the files but if it worked till now with Eclipse shouldn't it work like that too?
Thanks for your help
 
Joe Ess
Bartender
Posts: 9429
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Scarbez Seeker:

C:\>java -DOMMITTED_ARG -jar package.class_containing_main start "C:\projects\current_project\build\XML"
Exception in thread "main" java.util.zip.ZipException: El sistema no puede halla
r el archivo especificado

The -jar argument requires a .jar file for an argument. I believe you are giving it a .class file.
 
Scarbez Seeker
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Joe Ess:

The -jar argument requires a .jar file for an argument. I believe you are giving it a .class file.

I am. As I did not have a manifest file in my jar I thought I had to pass it the full path name to it. If I pass the full jar file gives me the same error, though
 
Joe Ess
Bartender
Posts: 9429
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Scarbez Seeker:

I am. As I did not have a manifest file in my jar I thought I had to pass it the full path name to it. If I pass the full jar file gives me the same error, though

If your jar is not executable you just put the jar in the classpath:
java -cp myjarfile.jar mymainclass.class
In order to execute a jar file:
java -jar myjarfile.jar
your jar file must have the following entry in the manifest file:
Main-Class: mymainclass
Note that it is not followed by ".class".
You can check the content of your jar files with the command:
jar -tf myjarfile.jar
or with Winzip.
These topics and others are covered in the Jar Files Trail of the Java Tutorial.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!