You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by "Fabricio M. Sanchez" <fa...@pstonline.co.uk> on 2005/06/07 15:42:54 UTC

ZipException on javac task moving from jdk1.4 to jdk1.5

Hi there,

I've searched google, ant-faq and ant-manual and found nothing conclusive...

I have recently moved from java (jdk) 1.4.2 to 1.5.0_03.
I'm using ant 1.6.1 (I've tried ant 1.6.5 also, but the problem still
exists)

After deleting all classes and compiling using the javac task (target name
is compile, see code below), I then compile the source again. 
The first time I compile (using 'ant compile')it builds successfully.
When I compile again (without modifying any files) and only on jdk1.5.0_03
(it works fine on jdk1.4.2) I get the java.util.zip.ZipException.

Has this happened to anyone? Any ideas on what to do to resolve it?

Thank you for your time,

Fabricio

Code below....

---- Start of build.xml compile target ----
<!-- Compiles Application -->
  <target name="compile">
    <javac srcdir="${home}/${src}" destdir="${home}/${classes}"
           classpathref="compile-classpath"
           debug="on" optimize="off" deprecation="on"/>          <-- line
105 on build.xml (see output, below)
  </target>
---- End of build.xml compile target ----


---- Start of Ant Output ----
C:\current_with_version>ant compile
Buildfile: build.xml

compile:
    [javac] Compiling 13 source files to C:\current_with_version\classes
    [javac] error: error reading
C:\current_with_version\classes\com\esp\cost\CostElement.class; jav
a.util.zip.ZipException: error in opening zip file
    [javac] Note: Some input files use unchecked or unsafe operations.
    [javac] Note: Recompile with -Xlint:unchecked for details.
    [javac] 1 error

BUILD FAILED
C:\current_with_version\build.xml:105: Compile failed; see the compiler
error output for details.

Total time: 48 seconds
---- End of Ant Output ----

-- 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.323 / Virus Database: 267.6.4 - Release Date: 06/06/2005
 


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: ZipException on javac task moving from jdk1.4 to jdk1.5

Posted by Peter Reilly <pe...@apache.org>.
What I wrote below is incorrect.
The problem is due to a difference between javac in jdk1.4 and jdk 1.5.
This can be seen on the command line:

preilly@angel:~/tmp/test > export JAVA_HOME=/usr/java/j2sdk1.4.2
preilly@angel:~/tmp/test > export PATH=$JAVA_HOME/bin:$PATH
preilly@angel:~/tmp/test > javac -classpath hello.java hello.java
preilly@angel:~/tmp/test > export JAVA_HOME=/usr/java/jdk1.5.0
preilly@angel:~/tmp/test > export PATH=$JAVA_HOME/bin:$PATH
preilly@angel:~/tmp/test > javac -classpath hello.java hello.java
error: error reading hello.java; java.util.zip.ZipException: error in 
opening zip file
1 error

Sorry for the misleading analysis!

Peter


Peter Reilly wrote:

> Peter Reilly wrote:
>
>> This should be a FAQ!
>>
>> You have a .class file in your class path (i.e. not a directory
>> or a .jar file). Starting with ant 1.6, ant will open the
>> files in the classpath checking for manifest entries. This attempted 
>> opening
>> will fail with the error "java.util.zip.ZipException"
>>
>> The problem does not exist with ant 1.5 as it does not try to
>> open the files. - so make sure that your classpath's
>
>
> In your case it would be the value
> of the reference "compile-classpath".
>
> Peter
>
>> do not
>> contain .class files.
>>
>> Peter
>>
>>
>> Fabricio M. Sanchez wrote:
>>
>>> Hi there,
>>>
>>> I've searched google, ant-faq and ant-manual and found nothing 
>>> conclusive...
>>>
>>> I have recently moved from java (jdk) 1.4.2 to 1.5.0_03.
>>> I'm using ant 1.6.1 (I've tried ant 1.6.5 also, but the problem still
>>> exists)
>>>
>>> After deleting all classes and compiling using the javac task 
>>> (target name
>>> is compile, see code below), I then compile the source again. The 
>>> first time I compile (using 'ant compile')it builds successfully.
>>> When I compile again (without modifying any files) and only on 
>>> jdk1.5.0_03
>>> (it works fine on jdk1.4.2) I get the java.util.zip.ZipException.
>>>
>>> Has this happened to anyone? Any ideas on what to do to resolve it?
>>>
>>> Thank you for your time,
>>>
>>> Fabricio
>>>
>>> Code below....
>>>
>>> ---- Start of build.xml compile target ----
>>> <!-- Compiles Application -->
>>>  <target name="compile">
>>>    <javac srcdir="${home}/${src}" destdir="${home}/${classes}"
>>>           classpathref="compile-classpath"
>>>           debug="on" optimize="off" deprecation="on"/>          <-- 
>>> line
>>> 105 on build.xml (see output, below)
>>>  </target>
>>> ---- End of build.xml compile target ----
>>>
>>>
>>> ---- Start of Ant Output ----
>>> C:\current_with_version>ant compile
>>> Buildfile: build.xml
>>>
>>> compile:
>>>    [javac] Compiling 13 source files to C:\current_with_version\classes
>>>    [javac] error: error reading
>>> C:\current_with_version\classes\com\esp\cost\CostElement.class; jav
>>> a.util.zip.ZipException: error in opening zip file
>>>    [javac] Note: Some input files use unchecked or unsafe operations.
>>>    [javac] Note: Recompile with -Xlint:unchecked for details.
>>>    [javac] 1 error
>>>
>>> BUILD FAILED
>>> C:\current_with_version\build.xml:105: Compile failed; see the compiler
>>> error output for details.
>>>
>>> Total time: 48 seconds
>>> ---- End of Ant Output ----
>>>
>>>  
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
>> For additional commands, e-mail: user-help@ant.apache.org
>>
>>
>>
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: ZipException on javac task moving from jdk1.4 to jdk1.5

Posted by Peter Reilly <pe...@apache.org>.
Peter Reilly wrote:

> This should be a FAQ!
>
> You have a .class file in your class path (i.e. not a directory
> or a .jar file). Starting with ant 1.6, ant will open the
> files in the classpath checking for manifest entries. This attempted 
> opening
> will fail with the error "java.util.zip.ZipException"
>
> The problem does not exist with ant 1.5 as it does not try to
> open the files. - so make sure that your classpath's

In your case it would be the value
of the reference "compile-classpath".

Peter

> do not
> contain .class files.
>
> Peter
>
>
> Fabricio M. Sanchez wrote:
>
>> Hi there,
>>
>> I've searched google, ant-faq and ant-manual and found nothing 
>> conclusive...
>>
>> I have recently moved from java (jdk) 1.4.2 to 1.5.0_03.
>> I'm using ant 1.6.1 (I've tried ant 1.6.5 also, but the problem still
>> exists)
>>
>> After deleting all classes and compiling using the javac task (target 
>> name
>> is compile, see code below), I then compile the source again. The 
>> first time I compile (using 'ant compile')it builds successfully.
>> When I compile again (without modifying any files) and only on 
>> jdk1.5.0_03
>> (it works fine on jdk1.4.2) I get the java.util.zip.ZipException.
>>
>> Has this happened to anyone? Any ideas on what to do to resolve it?
>>
>> Thank you for your time,
>>
>> Fabricio
>>
>> Code below....
>>
>> ---- Start of build.xml compile target ----
>> <!-- Compiles Application -->
>>  <target name="compile">
>>    <javac srcdir="${home}/${src}" destdir="${home}/${classes}"
>>           classpathref="compile-classpath"
>>           debug="on" optimize="off" deprecation="on"/>          <-- line
>> 105 on build.xml (see output, below)
>>  </target>
>> ---- End of build.xml compile target ----
>>
>>
>> ---- Start of Ant Output ----
>> C:\current_with_version>ant compile
>> Buildfile: build.xml
>>
>> compile:
>>    [javac] Compiling 13 source files to C:\current_with_version\classes
>>    [javac] error: error reading
>> C:\current_with_version\classes\com\esp\cost\CostElement.class; jav
>> a.util.zip.ZipException: error in opening zip file
>>    [javac] Note: Some input files use unchecked or unsafe operations.
>>    [javac] Note: Recompile with -Xlint:unchecked for details.
>>    [javac] 1 error
>>
>> BUILD FAILED
>> C:\current_with_version\build.xml:105: Compile failed; see the compiler
>> error output for details.
>>
>> Total time: 48 seconds
>> ---- End of Ant Output ----
>>
>>  
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


SOLVED: ZipException on javac task moving from jdk1.4 to jdk1.5

Posted by "Fabricio M. Sanchez" <fa...@pstonline.co.uk>.
Thank you very much, problem is solved!

Maurice, my JAVA_HOME was set to the correct jdk 1.5.0_03 that was being
used by my javac task (I unistalled jdk 1.4.2 to be sure!), thanks for that!

Stefan and Peter, bingo! I did have generated .class files on my
classpath!!!

I followed Peter's advice and removed any references to .class files that
were being generated from my classpath reference
"compile-classpath". This stopped the ZipExceptions appearing, and it builds
successfully again!!!

Although, this doesn't explain why the error did not occurr (with both ant
1.6.1 and 1.6.5) while I was using jdk1.4.2. The error happened only when I
moved to jdk 1.5.0_03....? Maybe it has come back from jdk1.3 as Stefan
suggested...

Thanks again!

Fabricio


-----Original Message-----
From: Peter Reilly [mailto:peterreilly@apache.org] 
Sent: 07 June 2005 22:48
To: Ant Users List
Subject: Re: ZipException on javac task moving from jdk1.4 to jdk1.5


This should be a FAQ!

You have a .class file in your class path (i.e. not a directory or a .jar
file). Starting with ant 1.6, ant will open the files in the classpath
checking for manifest entries. This attempted opening will fail with the
error "java.util.zip.ZipException"

The problem does not exist with ant 1.5 as it does not try to open the
files. - so make sure that your classpath's do not contain .class files.

Peter


Fabricio M. Sanchez wrote:

>Hi there,
>
>I've searched google, ant-faq and ant-manual and found nothing 
>conclusive...
>
>I have recently moved from java (jdk) 1.4.2 to 1.5.0_03.
>I'm using ant 1.6.1 (I've tried ant 1.6.5 also, but the problem still
>exists)
>
>After deleting all classes and compiling using the javac task (target 
>name is compile, see code below), I then compile the source again. The 
>first time I compile (using 'ant compile')it builds successfully. When 
>I compile again (without modifying any files) and only on jdk1.5.0_03 
>(it works fine on jdk1.4.2) I get the java.util.zip.ZipException.
>
>Has this happened to anyone? Any ideas on what to do to resolve it?
>
>Thank you for your time,
>
>Fabricio
>
>Code below....
>
>---- Start of build.xml compile target ----
><!-- Compiles Application -->
>  <target name="compile">
>    <javac srcdir="${home}/${src}" destdir="${home}/${classes}"
>           classpathref="compile-classpath"
>           debug="on" optimize="off" deprecation="on"/>          <-- line
>105 on build.xml (see output, below)
>  </target>
>---- End of build.xml compile target ----
>
>
>---- Start of Ant Output ----
>C:\current_with_version>ant compile
>Buildfile: build.xml
>
>compile:
>    [javac] Compiling 13 source files to C:\current_with_version\classes
>    [javac] error: error reading 
>C:\current_with_version\classes\com\esp\cost\CostElement.class; jav
>a.util.zip.ZipException: error in opening zip file
>    [javac] Note: Some input files use unchecked or unsafe operations.
>    [javac] Note: Recompile with -Xlint:unchecked for details.
>    [javac] 1 error
>
>BUILD FAILED
>C:\current_with_version\build.xml:105: Compile failed; see the compiler 
>error output for details.
>
>Total time: 48 seconds
>---- End of Ant Output ----
>
>  
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


-- 
No virus found in this incoming message.
Checked by AVG Anti-Virus.
Version: 7.0.323 / Virus Database: 267.6.4 - Release Date: 06/06/2005
 

-- 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.323 / Virus Database: 267.6.5 - Release Date: 07/06/2005
 


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: ZipException on javac task moving from jdk1.4 to jdk1.5

Posted by Peter Reilly <pe...@apache.org>.
This should be a FAQ!

You have a .class file in your class path (i.e. not a directory
or a .jar file). Starting with ant 1.6, ant will open the
files in the classpath checking for manifest entries. This attempted opening
will fail with the error "java.util.zip.ZipException"

The problem does not exist with ant 1.5 as it does not try to
open the files. - so make sure that your classpath's do not
contain .class files.

Peter


Fabricio M. Sanchez wrote:

>Hi there,
>
>I've searched google, ant-faq and ant-manual and found nothing conclusive...
>
>I have recently moved from java (jdk) 1.4.2 to 1.5.0_03.
>I'm using ant 1.6.1 (I've tried ant 1.6.5 also, but the problem still
>exists)
>
>After deleting all classes and compiling using the javac task (target name
>is compile, see code below), I then compile the source again. 
>The first time I compile (using 'ant compile')it builds successfully.
>When I compile again (without modifying any files) and only on jdk1.5.0_03
>(it works fine on jdk1.4.2) I get the java.util.zip.ZipException.
>
>Has this happened to anyone? Any ideas on what to do to resolve it?
>
>Thank you for your time,
>
>Fabricio
>
>Code below....
>
>---- Start of build.xml compile target ----
><!-- Compiles Application -->
>  <target name="compile">
>    <javac srcdir="${home}/${src}" destdir="${home}/${classes}"
>           classpathref="compile-classpath"
>           debug="on" optimize="off" deprecation="on"/>          <-- line
>105 on build.xml (see output, below)
>  </target>
>---- End of build.xml compile target ----
>
>
>---- Start of Ant Output ----
>C:\current_with_version>ant compile
>Buildfile: build.xml
>
>compile:
>    [javac] Compiling 13 source files to C:\current_with_version\classes
>    [javac] error: error reading
>C:\current_with_version\classes\com\esp\cost\CostElement.class; jav
>a.util.zip.ZipException: error in opening zip file
>    [javac] Note: Some input files use unchecked or unsafe operations.
>    [javac] Note: Recompile with -Xlint:unchecked for details.
>    [javac] 1 error
>
>BUILD FAILED
>C:\current_with_version\build.xml:105: Compile failed; see the compiler
>error output for details.
>
>Total time: 48 seconds
>---- End of Ant Output ----
>
>  
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: ZipException on javac task moving from jdk1.4 to jdk1.5

Posted by Maurice Feskanich <Ma...@Sun.COM>.
Don't know if this will help, but I've seen some strange exceptions
moving from jdk 1.4.x to 1.5.x if the JAVA_HOME env var doesn't point to
the same jdk version as the compiler used by the javac task.  Make sure
things are in sync.  If nothing else, it will rule this out as the cause.

Maury


Fabricio M. Sanchez wrote:
> Hi there,
> 
> I've searched google, ant-faq and ant-manual and found nothing conclusive...
> 
> I have recently moved from java (jdk) 1.4.2 to 1.5.0_03.
> I'm using ant 1.6.1 (I've tried ant 1.6.5 also, but the problem still
> exists)
> 
> After deleting all classes and compiling using the javac task (target name
> is compile, see code below), I then compile the source again. 
> The first time I compile (using 'ant compile')it builds successfully.
> When I compile again (without modifying any files) and only on jdk1.5.0_03
> (it works fine on jdk1.4.2) I get the java.util.zip.ZipException.
> 
> Has this happened to anyone? Any ideas on what to do to resolve it?
> 
> Thank you for your time,
> 
> Fabricio
> 
> Code below....
> 
> ---- Start of build.xml compile target ----
> <!-- Compiles Application -->
>   <target name="compile">
>     <javac srcdir="${home}/${src}" destdir="${home}/${classes}"
>            classpathref="compile-classpath"
>            debug="on" optimize="off" deprecation="on"/>          <-- line
> 105 on build.xml (see output, below)
>   </target>
> ---- End of build.xml compile target ----
> 
> 
> ---- Start of Ant Output ----
> C:\current_with_version>ant compile
> Buildfile: build.xml
> 
> compile:
>     [javac] Compiling 13 source files to C:\current_with_version\classes
>     [javac] error: error reading
> C:\current_with_version\classes\com\esp\cost\CostElement.class; jav
> a.util.zip.ZipException: error in opening zip file
>     [javac] Note: Some input files use unchecked or unsafe operations.
>     [javac] Note: Recompile with -Xlint:unchecked for details.
>     [javac] 1 error
> 
> BUILD FAILED
> C:\current_with_version\build.xml:105: Compile failed; see the compiler
> error output for details.
> 
> Total time: 48 seconds
> ---- End of Ant Output ----
> 

-- 
Maury Feskanich
 DReAM Support


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: ZipException on javac task moving from jdk1.4 to jdk1.5

Posted by Stefan Bodewig <bo...@apache.org>.
On Tue, 7 Jun 2005, Fabricio M. Sanchez <fa...@pstonline.co.uk>
wrote:

> After deleting all classes and compiling using the javac task
> (target name is compile, see code below), I then compile the source
> again. The first time I compile (using 'ant compile')it builds
> successfully.  When I compile again (without modifying any files)

Does your build process modify any jar file that is on your 
compile-classpath <path>?  Or even worse on CLASSPATH?

I've seen exceptions like this in JDK 1.3 if you modify jars that the
Java VM has opened earlier.  Maybe this has come back in 1.5.

Stefan

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org