Skip to main content

javap ignores Class-Path manifest entry

Posted by ss141213 on October 14, 2009 at 12:04 AM PDT

Did you know javap ignores Class-Path manifest attribute where as javac honors it? I didn't. Now I know. I have a jar called foo.jar with following manifest entry:

Manifest-Version: 1.0
Class-Path: javax.ejb.jar
Created-By: 1.6.0_16 (Sun Microsystems Inc.)

javax.ejb.jar contains all the EJB APIs and it is in the same directory as foo.jar. Yet, this is what I see when I run javap:

javap -classpath foo.jar javax.ejb.EJB
ERROR:Could not find javax.ejb.EJB

On the other hand, javac works fine. e.g., I could successfully compile the following file:

@javax.ejb.EJB 
public class A {}

like this:

javac -classpath foo.jar A.java

It definitely looks like a bug in javap. The situation that prompted me to this experiment is we are trying to create some empty jars in glassfish/lib directory which would have Class-Path manifest reference to glassfish/modules directory. We need those empty jars as we have advertised about them in previous versions of GlassFish and our users use them in classpath during compilation, so we don't want to break their build scripts. I was trying to find out what java commands can consume those empty jars. At this point, javap can't. I am using Sun JDK 1.6.0_16-b01. It's not that bad considering javac can consume them and that takes care of our existing users' need.

Related Topics >>