javac and zip/jar files that contain only sources
My program depends upon library classes written by someone else. These are distributed in a zip file containing only the .java files. I want to include that zip file in my javac sourcepath so that the classes will be compiled into the same place as the class files from the code I have written.
I'm using the command:
javac -d ../build -sourcepath .;..\lib\lib.zip mypackage\myclass.java
When executed I get an error for every one of the third party files saying "class x is public, should be declared in a file named x.java". It IS in a file named that, it's just that the file is inside a zip. The compiler is obviously finding the file.
Is this a limitation of javac? If so, it's not one that I can find any documentation for.
I know I can just unzip the thing, but I'm trying to put together an idiot-proof distribution and I'd like to include the 3rd-party stuff (which is open source) in exactly the format it's distributed in.
[976 byte] By [
rfletch6a] at [2007-9-27 5:05:03]

It may not work (last time I tried something similar was in JDK 1.2, with files distributed in a Jar) but try:
javac -d ../build -classpath ..\lib\lib.zip -sourcepath . mypackage\myclass.java
IIRC, it resulted in compiling the source files (including those in the Jar) as required. :-/
Though, open source stuff does sometimes have a Jar file containing the class files - Seeing if one exists for your application may be worth a look. I personally try to make my Jars contain both sources and classes so that it may be easily implemented in a 3rd-party product. :-)
Bhav
bump
i'm not getting this problem and would be interested to hear any explanations
basically, i have jar files and i've been using them with no problems. Now all of the sudden I have a JSP that won't compile because of this. Here is the error I get (and yes, the classes are declared properly and this isn't the case sensative issue):
[10/28/05 10:21:38:092 EDT] 4e5f5c34 WebGroupE SRVE0026E: [Servlet Error]-[Unable to compile class for JSP
C:\WebSphere\AppServer\installedApps\DefaultNode\grc\lib\webapi-model-1.0.jar(com/vacationclub/webapi/model/webuser/IndividualWebUser.java):5: class IndividualWebUser is public, should be declared in a file named IndividualWebUser.java
(source unavailable)
C:\WebSphere\AppServer\installedApps\DefaultNode\grc\lib\webapi-model-1.0.jar(com/vacationclub/webapi/model/webuser/WebUser.java):5: class WebUser is public, should be declared in a file named WebUser.java
(source unavailable)
C:\WebSphere\AppServer\installedApps\DefaultNode\grc\lib\webapi-model-1.0.jar(com/vacationclub/webapi/model/webuser/IWebUser.java):4: class IWebUser is public, should be declared in a file named IWebUser.java
(source unavailable)
C:\WebSphere\AppServer\installedApps\DefaultNode\grc\lib\webapi-model-1.0.jar(com/vacationclub/webapi/model/webuser/ForeignSystemUser.java):13: class ForeignSystemUser is public, should be declared in a file named ForeignSystemUser.java
(source unavailable)
C:\WebSphere\AppServer\installedApps\DefaultNode\grc\lib\webapi-model-1.0.jar(com/vacationclub/webapi/model/webuser/SystemKey.java):15: class SystemKey is public, should be declared in a file named SystemKey.java
(source unavailable)
C:\WebSphere\AppServer\installedApps\DefaultNode\grc\lib\webapi-model-1.0.jar(com/vacationclub/webapi/model/webuser/ISystemKey.java):18: class ISystemKey is public, should be declared in a file named ISystemKey.java
(source unavailable)
6 errors
]: org.apache.jasper.JasperException: Unable to compile class for JSP
C:\WebSphere\AppServer\installedApps\DefaultNode\grc\lib\webapi-model-1.0.jar(com/vacationclub/webapi/model/webuser/IndividualWebUser.java):5: class IndividualWebUser is public, should be declared in a file named IndividualWebUser.java
(source unavailable)
C:\WebSphere\AppServer\installedApps\DefaultNode\grc\lib\webapi-model-1.0.jar(com/vacationclub/webapi/model/webuser/WebUser.java):5: class WebUser is public, should be declared in a file named WebUser.java
(source unavailable)
C:\WebSphere\AppServer\installedApps\DefaultNode\grc\lib\webapi-model-1.0.jar(com/vacationclub/webapi/model/webuser/IWebUser.java):4: class IWebUser is public, should be declared in a file named IWebUser.java
(source unavailable)
C:\WebSphere\AppServer\installedApps\DefaultNode\grc\lib\webapi-model-1.0.jar(com/vacationclub/webapi/model/webuser/ForeignSystemUser.java):13: class ForeignSystemUser is public, should be declared in a file named ForeignSystemUser.java
(source unavailable)
C:\WebSphere\AppServer\installedApps\DefaultNode\grc\lib\webapi-model-1.0.jar(com/vacationclub/webapi/model/webuser/SystemKey.java):15: class SystemKey is public, should be declared in a file named SystemKey.java
(source unavailable)
C:\WebSphere\AppServer\installedApps\DefaultNode\grc\lib\webapi-model-1.0.jar(com/vacationclub/webapi/model/webuser/ISystemKey.java):18: class ISystemKey is public, should be declared in a file named ISystemKey.java
(source unavailable)
6 errors