Strange problem with .jar and .class files

Discussion in 'Java' started by Eric Tonissen, Jan 12, 2012.

  1. I have a Java program normal running. I needed some .class files from
    another project, builded an .jar file from it, added this to the
    classpath and it works.

    But now we decided not to use the .class files anymore but to make a
    copy from the corresponding sources to my own project.
    So I did. But now I have a lot of compile errors about sources which
    it also needs ?

    I unzipped all the .jars files on the class path, but they are also
    not in here.

    Is it possible that the compiler includes information into the .class
    files, so it doesn't need the other .class files anymore?
    Eric Tonissen, Jan 12, 2012
    #1
    1. Advertising

  2. Eric Tonissen

    Jeff Higgins Guest

    On 01/12/2012 06:40 AM, Eric Tonissen wrote:
    > I have a Java program normal running. I needed some .class files from
    > another project, builded an .jar file from it, added this to the
    > classpath and it works.
    >
    > But now we decided not to use the .class files anymore but to make a
    > copy from the corresponding sources to my own project.
    > So I did. But now I have a lot of compile errors about sources which
    > it also needs ?
    >


    The third party project you are attempting to build has dependencies
    which the compiler cannot resolve is the way I read this so far.

    > I unzipped all the .jars files on the class path, but they are also
    > not in here.


    You are not able as yet to find the required dependencies.

    >
    > Is it possible that the compiler includes information into the .class
    > files, so it doesn't need the other .class files anymore?


    No, if I understand the question to be "has the third party packager's
    build or packaging process hidden the required dependencies in some
    other class file".

    You must find the required dependencies and add them to your build and
    packaging process.
    Jeff Higgins, Jan 12, 2012
    #2
    1. Advertising

  3. Eric Tonissen

    Lew Guest

    Jeff Higgins wrote:
    > Eric Tonissen wrote:
    >> I have a Java program normal running. I needed some .class files from
    >> another project, builded an .jar file from it, added this to the
    >> classpath and it works.
    >>
    >> But now we decided not to use the .class files anymore but to make a
    >> copy from the corresponding sources to my own project.


    Why? Why?

    >> So I did. But now I have a lot of compile errors about sources which
    >> it also needs ?


    And there's the "why not".

    > The third party project you are attempting to build has dependencies which the
    > compiler cannot resolve is the way I read this so far.
    >
    >> I unzipped all the .jars files on the class path, but they are also
    >> not in here.

    >
    > You are not able as yet to find the required dependencies.


    And you are not following a good strategy.

    >> Is it possible that the compiler includes information into the .class
    >> files, so it doesn't need the other .class files anymore?

    >
    > No, if I understand the question to be "has the third party packager's build
    > or packaging process hidden the required dependencies in some other class file".
    >
    > You must find the required dependencies and add them to your build and
    > packaging process.


    But basically unpacking from a JAR and repacking into a different one is not a
    good practice. It defeats the whole point of JARs, and as the OP has found,
    opens a world of hurt trying to recapitulate everything that went into the JAR
    build. And if the JAR is third party, you really have to watch out for
    intellectual property rights. OP, why in the frak are you going down such an
    unproductive path?

    --
    Lew
    Honi soit qui mal y pense.
    http://upload.wikimedia.org/wikipedia/commons/c/cf/Friz.jpg
    Lew, Jan 12, 2012
    #3
  4. Eric Tonissen

    Jeff Higgins Guest

    On 01/12/2012 11:14 AM, Lew wrote:
    > Jeff Higgins wrote:
    >> Eric Tonissen wrote:
    >>> I have a Java program normal running. I needed some .class files from
    >>> another project, builded an .jar file from it, added this to the
    >>> classpath and it works.
    >>>
    >>> But now we decided not to use the .class files anymore but to make a
    >>> copy from the corresponding sources to my own project.

    >
    > Why? Why?
    >

    It's a good question, but
    I sometimes have difficulty questioning motives right off the bat.
    For instance another poster's intent to produce a "human readable" ascii
    output of a 10,000 X 10,000 floating point matrix.
    Jeff Higgins, Jan 12, 2012
    #4
  5. Eric Tonissen

    Roedy Green Guest

    On Thu, 12 Jan 2012 03:40:56 -0800 (PST), Eric Tonissen
    <> wrote, quoted or indirectly quoted someone
    who said :

    >Is it possible that the compiler includes information into the .class
    >files, so it doesn't need the other .class files anymore?


    static finals can get converted to int or String literals that no
    longer reference the original class. That is why you need clean
    compiles if you have inter class references of static finals that you
    have changed.

    The compiler has to be able to see everything referenced, either as
    source on the sourcepath or class files on the classpath
    --
    Roedy Green Canadian Mind Products
    http://mindprod.com
    One of the most useful comments you can put in a program is
    "If you change this, remember to change ?XXX? too".
    Roedy Green, Jan 12, 2012
    #5
  6. Eric Tonissen

    Lew Guest

    On Thursday, January 12, 2012 9:34:21 AM UTC-8, Jeff Higgins wrote:
    > On 01/12/2012 11:14 AM, Lew wrote:
    > > Jeff Higgins wrote:
    > >> Eric Tonissen wrote:
    > >>> I have a Java program normal running. I needed some .class files from
    > >>> another project, builded an .jar file from it, added this to the
    > >>> classpath and it works.
    > >>>
    > >>> But now we decided not to use the .class files anymore but to make a
    > >>> copy from the corresponding sources to my own project.

    > >
    > > Why? Why?
    > >

    > It's a good question, but
    > I sometimes have difficulty questioning motives right off the bat.
    > For instance another poster's intent to produce a "human readable" ascii
    > output of a 10,000 X 10,000 floating point matrix.


    The answer to "why?" informs the answer to "what?"

    As Patricia and others often advise posters, tell us the goal, not just your current, possibly flawed idea of implementation. If we know why the OP wants to do such a thing, on the face of it difficult and unrewarding, we might be able to suggest an easy and satisfying way of achieving the goal.

    --
    Lew
    Lew, Jan 12, 2012
    #6
  7. Eric Tonissen

    Jeff Higgins Guest

    On 01/12/2012 04:42 PM, Lew wrote:
    > On Thursday, January 12, 2012 9:34:21 AM UTC-8, Jeff Higgins wrote:
    >> On 01/12/2012 11:14 AM, Lew wrote:
    >>> Jeff Higgins wrote:
    >>>> Eric Tonissen wrote:
    >>>>> I have a Java program normal running. I needed some .class files from
    >>>>> another project, builded an .jar file from it, added this to the
    >>>>> classpath and it works.
    >>>>>
    >>>>> But now we decided not to use the .class files anymore but to make a
    >>>>> copy from the corresponding sources to my own project.
    >>>
    >>> Why? Why?
    >>>

    >> It's a good question, but
    >> I sometimes have difficulty questioning motives right off the bat.
    >> For instance another poster's intent to produce a "human readable" ascii
    >> output of a 10,000 X 10,000 floating point matrix.

    >
    > The answer to "why?" informs the answer to "what?"
    >
    > As Patricia and others often advise posters, tell us the goal, not just your current, possibly flawed idea of implementation. If we know why the OP wants to do such a thing, on the face of it difficult and unrewarding, we might be able to suggest an easy and satisfying way of achieving the goal.
    >

    Good advice.
    Perhaps I was reading my own motivations into the OP.
    I've had occasion to be dissatisfied with the packaging of "third party"
    and even my own code.

    I think I may not have precisely understood the process described by the
    OP.
    Referencing the two paragraphs above.

    Beginning with "I have a Java program ...",
    I can read this several ways:
    a) I snagged some binary class files from another project and packaged
    them in a jar,or
    b) I built and jar packaged another project using it's own build process,or
    c) I built (perhaps a subset) of the classes from another project and
    packaged them in a jar.

    Beginning with "But now we decided ..."
    I suspect here is where the process breaks:
    It sounds like:
    I am attempting to build (perhaps a subset of) another project using my
    own build process.

    If I look at for instance Javolution library, their build process
    includes a non-standard text substitution step to include or not Java
    generics.
    Jeff Higgins, Jan 13, 2012
    #7
  8. Eric Tonissen

    Lew Guest

    Lew, Jan 13, 2012
    #8
  9. Eric Tonissen

    Jeff Higgins Guest

    On 01/13/2012 12:05 AM, Lew wrote:
    > Jeff Higgins wrote:
    >> If I look at for instance Javolution library, their build process
    >> includes a
    >> non-standard text substitution step to include or not Java generics.

    >
    > ??!
    >

    A method signature in the .templates.javolution.text package:
    public final Appendable/*TextBuilder*/ append(char c)
    becomes
    public final Appendable<TextBuilder> append(char c)
    in the javolution.text package before compilation.
    Jeff Higgins, Jan 13, 2012
    #9
  10. Eric Tonissen

    Jeff Higgins Guest

    On 01/13/2012 03:41 AM, Jeff Higgins wrote:
    > On 01/13/2012 12:05 AM, Lew wrote:
    >> Jeff Higgins wrote:
    >>> If I look at for instance Javolution library, their build process
    >>> includes a
    >>> non-standard text substitution step to include or not Java generics.

    >>
    >> ??!
    >>

    > A method signature in the .templates.javolution.text package:
    > public final Appendable/*TextBuilder*/ append(char c)
    > becomes
    > public final Appendable<TextBuilder> append(char c)
    > in the javolution.text package before compilation.
    >

    or not, depending upon the build parameters.

    Which is apropos the OP, if that is your question,
    if his process worked when he snagged some binaries
    and didn't work when he attempted to build from source.

    Which is one imagined scenario from a world of others.
    Jeff Higgins, Jan 13, 2012
    #10
  11. On 12 jan, 12:40, Eric Tonissen <> wrote:
    > I have a Java program normal running. I needed some .class files from
    > another project, builded an .jar file from it, added this to the
    > classpath and it works.
    >
    > But now we decided not to use the .class files anymore but to make a
    > copy from the corresponding sources to my own project.
    > So I did. But now I have a lot of compile errors about sources which
    > it also needs ?
    >
    > I unzipped all the .jars files on the class path, but they are also
    > not in here.
    >
    > Is it possible that the compiler includes information into the .class
    > files, so it doesn't need the other .class files anymore?


    We find out that the java used lazy loading of the class-files at
    runtime.
    So an import of a class is only done when needed.
    That's why, when I copied only the sources of the class-files to my
    project I got compile errors.
    Because these sources has methods which I don't use, but needs sources
    which are not available.

    Thanks for your help.
    Eric Tonissen, Jan 13, 2012
    #11
  12. Eric Tonissen

    Lew Guest

    On 01/13/2012 01:08 AM, Jeff Higgins wrote:
    > On 01/13/2012 03:41 AM, Jeff Higgins wrote:
    >> On 01/13/2012 12:05 AM, Lew wrote:
    >>> Jeff Higgins wrote:
    >>>> If I look at for instance Javolution library, their build process
    >>>> includes a
    >>>> non-standard text substitution step to include or not Java generics.
    >>>
    >>> ??!
    >>>

    >> A method signature in the .templates.javolution.text package:
    >> public final Appendable/*TextBuilder*/ append(char c)
    >> becomes
    >> public final Appendable<TextBuilder> append(char c)
    >> in the javolution.text package before compilation.
    >>

    > or not, depending upon the build parameters.


    And again I say,

    ??!



    --
    Lew
    Honi soit qui mal y pense.
    http://upload.wikimedia.org/wikipedia/commons/c/cf/Friz.jpg
    Lew, Jan 13, 2012
    #12
  13. Eric Tonissen

    Lew Guest

    On 01/13/2012 02:24 AM, Eric Tonissen wrote:
    > On 12 jan, 12:40, Eric Tonissen<> wrote:
    >> I have a Java program normal running. I needed some .class files from
    >> another project, builded an .jar file from it, added this to the
    >> classpath and it works.
    >>
    >> But now we decided not to use the .class files anymore but to make a
    >> copy from the corresponding sources to my own project.
    >> So I did. But now I have a lot of compile errors about sources which
    >> it also needs ?
    >>
    >> I unzipped all the .jars files on the class path, but they are also
    >> not in here.
    >>
    >> Is it possible that the compiler includes information into the .class
    >> files, so it doesn't need the other .class files anymore?

    >
    > We find out that the java used lazy loading of the class-files at
    > runtime.
    > So an import of a class is only done when needed.
    > That's why, when I copied only the sources of the class-files to my
    > project I got compile errors.
    > Because these sources has methods which I don't use, but needs sources
    > which are not available.


    Why have you not answered my question? You came here asking for help but
    refused to interact with any of us. You didn't even answer a direct question.
    What's that all about? Hm?

    You do know this is a discussion group and not a help desk, right? And that
    interacting with us would have helped you *more*? Hm?

    --
    Lew
    Honi soit qui mal y pense.
    http://upload.wikimedia.org/wikipedia/commons/c/cf/Friz.jpg
    Lew, Jan 13, 2012
    #13
  14. Eric Tonissen

    Jeff Higgins Guest

    On 01/13/2012 10:40 AM, Lew wrote:
    > On 01/13/2012 01:08 AM, Jeff Higgins wrote:
    >> On 01/13/2012 03:41 AM, Jeff Higgins wrote:
    >>> On 01/13/2012 12:05 AM, Lew wrote:
    >>>> Jeff Higgins wrote:
    >>>>> If I look at for instance Javolution library, their build process
    >>>>> includes a
    >>>>> non-standard text substitution step to include or not Java generics.
    >>>>
    >>>> ??!
    >>>>
    >>> A method signature in the .templates.javolution.text package:
    >>> public final Appendable/*TextBuilder*/ append(char c)
    >>> becomes
    >>> public final Appendable<TextBuilder> append(char c)
    >>> in the javolution.text package before compilation.
    >>>

    >> or not, depending upon the build parameters.

    >
    > And again I say,
    >
    > ??!
    >

    I don't understand the question(exclamation).
    Jeff Higgins, Jan 13, 2012
    #14
  15. Eric Tonissen

    Jeff Higgins Guest

    On 01/13/2012 10:42 AM, Lew wrote:
    > On 01/13/2012 02:24 AM, Eric Tonissen wrote:
    >> On 12 jan, 12:40, Eric Tonissen<> wrote:
    >>> I have a Java program normal running. I needed some .class files from
    >>> another project, builded an .jar file from it, added this to the
    >>> classpath and it works.
    >>>
    >>> But now we decided not to use the .class files anymore but to make a
    >>> copy from the corresponding sources to my own project.
    >>> So I did. But now I have a lot of compile errors about sources which
    >>> it also needs ?
    >>>
    >>> I unzipped all the .jars files on the class path, but they are also
    >>> not in here.
    >>>
    >>> Is it possible that the compiler includes information into the .class
    >>> files, so it doesn't need the other .class files anymore?

    >>
    >> We find out that the java used lazy loading of the class-files at
    >> runtime.
    >> So an import of a class is only done when needed.
    >> That's why, when I copied only the sources of the class-files to my
    >> project I got compile errors.
    >> Because these sources has methods which I don't use, but needs sources
    >> which are not available.

    >
    > Why have you not answered my question? You came here asking for help but
    > refused to interact with any of us. You didn't even answer a direct
    > question. What's that all about? Hm?
    >
    > You do know this is a discussion group and not a help desk, right? And
    > that interacting with us would have helped you *more*? Hm?
    >

    The only questions you posed to the OP that I saw were:

    "Why? Why?" and
    "OP, why in the frak are you going down such an unproductive path?"
    both bleated in a reply to one of my posts, not directly to a post by
    Eric Tonissen. Maybe he didn't see them. Maybe he chose to ignore them.
    After all you did come close to gratuitously impugning his moral
    integrity with your parting shot concerning intellectual property rights.
    Jeff Higgins, Jan 13, 2012
    #15
  16. Eric Tonissen

    Lew Guest

    On Friday, January 13, 2012 9:55:25 AM UTC-8, Jeff Higgins wrote:
    > On 01/13/2012 10:40 AM, Lew wrote:
    > > On 01/13/2012 01:08 AM, Jeff Higgins wrote:
    > >> On 01/13/2012 03:41 AM, Jeff Higgins wrote:
    > >>> On 01/13/2012 12:05 AM, Lew wrote:
    > >>>> Jeff Higgins wrote:
    > >>>>> If I look at for instance Javolution library, their build process
    > >>>>> includes a
    > >>>>> non-standard text substitution step to include or not Java generics..
    > >>>>
    > >>>> ??!
    > >>>>
    > >>> A method signature in the .templates.javolution.text package:
    > >>> public final Appendable/*TextBuilder*/ append(char c)
    > >>> becomes
    > >>> public final Appendable<TextBuilder> append(char c)
    > >>> in the javolution.text package before compilation.
    > >>>
    > >> or not, depending upon the build parameters.

    > >
    > > And again I say,
    > >
    > > ??!
    > >

    > I don't understand the question(exclamation).


    Fair enough. I'm expressing puzzlement and shock at the idea of pre-processing Java code for generics or not. It seems so bassackwards and unnecessary, though I'm sure they thought they were clever to do this. I might have contented my self with a -target 1.4 (and appropriate bootclasspath) ratherthan manipulating source, presumably to support a ten-year-old version of Java.

    Or better, freeze the Java 1.4 library and just freaking use the freaking generics for all current work.

    So I was expressing my "WTF?" over their technique.

    --
    Lew
    Lew, Jan 13, 2012
    #16
  17. Eric Tonissen

    Lew Guest

    Jeff Higgins wrote:
    > Lew wrote:
    > "Why? Why?" and
    > "OP, why in the frak are you going down such an unproductive path?"
    > both bleated in a reply to one of my posts, not directly to a post by
    > Eric Tonissen. Maybe he didn't see them. Maybe he chose to ignore them.
    > After all you did come close to gratuitously impugning his moral
    > integrity with your parting shot concerning intellectual property rights.


    I was cautioning him about IP rights, not impugning. It's a real risk whenyou start cracking JARs. Do you suggest he roll blithely forward if that were an issue? It seems like a reasonable thing to pay attention to when you're lifting source from a third party.

    And if he had read the responses to his post, he should have been able to figure out from the position of the question in the flow that my questions were directed to him. After all, that's why we reply in line, isn't it?

    And then I explained further why "why?" is an important question. You call that "bleating"?

    Sigh.

    --
    Lew
    Lew, Jan 13, 2012
    #17
  18. On 12-01-13 07:34 PM, Lew wrote:
    > On Friday, January 13, 2012 9:55:25 AM UTC-8, Jeff Higgins wrote:
    >> On 01/13/2012 10:40 AM, Lew wrote:
    >>> On 01/13/2012 01:08 AM, Jeff Higgins wrote:
    >>>> On 01/13/2012 03:41 AM, Jeff Higgins wrote:
    >>>>> On 01/13/2012 12:05 AM, Lew wrote:
    >>>>>> Jeff Higgins wrote:
    >>>>>>> If I look at for instance Javolution library, their build process
    >>>>>>> includes a
    >>>>>>> non-standard text substitution step to include or not Java generics.
    >>>>>>
    >>>>>> ??!
    >>>>>>
    >>>>> A method signature in the .templates.javolution.text package:
    >>>>> public final Appendable/*TextBuilder*/ append(char c)
    >>>>> becomes
    >>>>> public final Appendable<TextBuilder> append(char c)
    >>>>> in the javolution.text package before compilation.
    >>>>>
    >>>> or not, depending upon the build parameters.
    >>>
    >>> And again I say,
    >>>
    >>> ??!
    >>>

    >> I don't understand the question(exclamation).

    >
    > Fair enough. I'm expressing puzzlement and shock at the idea of pre-processing Java code for generics or not. It seems so bassackwards and unnecessary, though I'm sure they thought they were clever to do this. I might have contented my self with a -target 1.4 (and appropriate bootclasspath) rather than manipulating source, presumably to support a ten-year-old version of Java.
    >
    > Or better, freeze the Java 1.4 library and just freaking use the freaking generics for all current work.
    >
    > So I was expressing my "WTF?" over their technique.
    >

    I'm with you on this one. It occurs to me too that if someone is using
    1.5 or higher, there is going to be considerably more than just generics
    that get in the way: varargs, annotations, foreach, autoboxing...and the
    list continues. Then add in all the API updates, new methods or
    interfaces or classes, that might be in use that 1.5 has and 1.4 does not.

    I recently had to do some brand new J2SE 1.4 work, not to mention J2EE
    1.3 (Servlet 2.3 etc). Blast from the past it wasn't, but it wasn't a
    big job fortunately. It's a different world from 1.5+ and like you
    suggest it's best to keep codebases that use the one or the other
    compartmentalized and different. Otherwise you run the risk of keeping
    your 1.5+ stuff stupid...even if you employ nasty tricks like the one
    described above.

    Mind you, not so long before I also had to do a brief foray into J2SE
    1.3 work: don't ask. :) Imagine my chagrin when I discovered that
    String.split() only showed up in 1.4, I'd forgotten all about having to
    split strings with indexOf() many, many years ago. :)

    AHS

    --
    ....wherever the people are well informed they can be trusted with their
    own government...
    -- Thomas Jefferson, 1789
    Arved Sandstrom, Jan 14, 2012
    #18
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. cyril
    Replies:
    2
    Views:
    3,853
    cyril
    Aug 25, 2004
  2. Arnold Peters
    Replies:
    0
    Views:
    564
    Arnold Peters
    Jan 5, 2005
  3. muttley
    Replies:
    0
    Views:
    2,714
    muttley
    Oct 20, 2005
  4. cyberco
    Replies:
    4
    Views:
    3,745
    Roedy Green
    Feb 14, 2006
  5. Arnold Peters
    Replies:
    0
    Views:
    653
    Arnold Peters
    Jan 5, 2005
Loading...

Share This Page