Determining which versions of java a program will run on?

Discussion in 'Java' started by travel2light, Mar 8, 2008.

  1. travel2light

    travel2light Guest

    Is there a way to find this out? Thanks for any advice.

    Michael
     
    travel2light, Mar 8, 2008
    #1
    1. Advertising

  2. travel2light

    Jeff Higgins Guest

    travel2light wrote:

    Determining which versions of java a program will run on?

    > Is there a way to find this out? Thanks for any advice.
    >


    This article may help.
    Check out class file format.
    <http://www.javaworld.com/javaworld/javaqa/2003-05/02-qa-0523-version.html>
     
    Jeff Higgins, Mar 8, 2008
    #2
    1. Advertising

  3. On Mar 9, 2:26 am, travel2light <> wrote:
    > Is there a way to find this out?


    Please repeat subject line in the body of the message.

    What app.? Yours or someone elses?

    For your own, you might try compiling the code
    using the -bootclasspath option, and pointing it
    to the rt.jar of the earlier version.

    --
    Andrew T.
    PkySci.org
     
    Andrew Thompson, Mar 8, 2008
    #3
  4. travel2light

    Roedy Green Guest

    Roedy Green, Mar 8, 2008
    #4
  5. travel2light

    travel2light Guest

    On 8 Mar, 23:35, Andrew Thompson <> wrote:
    > On Mar 9, 2:26 am, travel2light <> wrote:
    >
    > > Is there a way to find this out?

    >
    > Please repeat subject line in the body of the message.


    No problem.

    >
    > What app.? Yours or someone elses?
    >
    > For your own, you might try compiling the code
    > using the -bootclasspath option, and pointing it
    > to the rt.jar of the earlier version.
    >
    > --
    > Andrew T.
    > PkySci.org


    This is my application. Actually I think I explained it incorrectly. I
    only want to find out what versions of java the compiled code will run
    on. I am using 1.6.0_03-b05. I don't intend to recompile it for
    different versions.

    Michael
     
    travel2light, Mar 9, 2008
    #5
  6. On Mar 9, 10:27 am, travel2light <> wrote:
    > On 8 Mar, 23:35, Andrew Thompson <> wrote:

    ...
    > > For your own (app), you might try compiling the code
    > > using the -bootclasspath option, and pointing it
    > > to the rt.jar of the earlier version.

    ...
    > ...I
    > only want to find out what versions of java the compiled code will run
    > on. I am using 1.6.0_03-b05. I don't intend to recompile it for
    > different versions.


    You don't need to. Any code that is compiled
    to run on Java 1.4 (for example) will also run
    just fine in Java 1.5 and 1.6 (etcetera).

    The -bootclasspath option is useful because
    it ensures the bytecodes are *really* compatible
    with the target minimum version, as opposed to
    simply having the bytecodes written in the form
    expected for 1.4. That is what Jeff was referring
    to when he mentioned the class file format.

    So, it works like this, you compile code
    using the 1.6 SDK, but specify the -bootclasspath
    option and point that towards a 1.4 rt.jar
    (as well, specify the -source and -target,
    but the -bootclasspath is the one most people
    miss).

    The binary will be compatible with 1.4+.

    Using -bootclasspath is also a good 'acid test'
    for whether the code is truly compatible with
    the target minimum version.

    --
    Andrew T.
    PhySci.org
     
    Andrew Thompson, Mar 9, 2008
    #6
  7. travel2light

    Arne Vajhøj Guest

    travel2light wrote:
    > Is there a way to find this out? Thanks for any advice.


    javap -verbose -classpath . yourpackage.YourClass

    will display major and minor version number.

    Version X will run on versions >X but not on version <X.

    Basically JDK version 1.n.x uses major version 44+n.

    Arne
     
    Arne Vajhøj, Mar 9, 2008
    #7
  8. On Sat, 08 Mar 2008 18:10:28 -0800, Andrew Thompson wrote:

    [Snip]
    > So, it works like this, you compile code
    > using the 1.6 SDK, but specify the -bootclasspath
    > option and point that towards a 1.4 rt.jar
    > (as well, specify the -source and -target,
    > but the -bootclasspath is the one most people
    > miss).


    I'm not the original poster, but I have a related question. You always
    see the -source and -target options used together and set to the same java
    version. Is this required these days. What I would like to do is to
    create a 1.4 class file from 1.6 sources using a 1.4 rt.jar. So I could
    use modern java language features, but restrict myself to the older
    libraries and produce a class file that can be read by older versions of
    the JRE?

    Am I asking too much here?

    Thanks.



    --
    Kenneth P. Turvey <>
     
    Kenneth P. Turvey, Mar 10, 2008
    #8
  9. On Mar 10, 10:41 am, "Kenneth P. Turvey" <kt-
    > wrote:
    ...
    > I'm not the original poster, but I have a related question.  You always
    > see the -source and -target options used together and set to the same java
    > version.  


    You might. I don't.

    -source never has any meaning below '1.3',
    whereas the -target might specify '1.1'.

    >..Is this required these days.  What I would like to do is to
    > create a 1.4 class file from 1.6 sources using a 1.4 rt.jar.  So I could
    > use modern java language features, but restrict myself to the older
    > libraries and produce a class file that can be read by older versions of
    > the JRE?  


    I am not entirely sure what you are asking,
    but note that generics (for e.g.) cannot be
    used in any code intended to run on 1.4.

    --
    Andrew T.
    PhySci.org
     
    Andrew Thompson, Mar 10, 2008
    #9
  10. On Sun, 09 Mar 2008 17:58:15 -0700, Andrew Thompson wrote:

    > I am not entirely sure what you are asking,
    > but note that generics (for e.g.) cannot be
    > used in any code intended to run on 1.4.


    Well, that would be one feature I would like. Would this give the modern
    looping constructs (a favorite of mine)? What about assertions?

    Thanks?



    --
    Kenneth P. Turvey <>
     
    Kenneth P. Turvey, Mar 10, 2008
    #10
  11. On Mar 10, 6:04 pm, "Kenneth P. Turvey" <>
    wrote:
    > On Sun, 09 Mar 2008 17:58:15 -0700, Andrew Thompson wrote:
    > > I am not entirely sure what you are asking,
    > > but note that generics (for e.g.) cannot be
    > > used in any code intended to run on 1.4.

    >
    > Well, that would be one feature I would like.  Would this give the modern
    > looping constructs (a favorite of mine)?  What about assertions?  


    I do not believe so, though the spec. gurus
    might be in a better position to advise.

    (shrugs) I usually 'specify the options and let
    the compiler decide'. Further, since I only too
    regularly need to design for binaries that will
    run on 1.4 or (shock/horror) 1.1, my enthusiasm
    for the 'new language constructs' has been somewhat
    lacking.

    > Thanks?


    I understand 'Thanks' and 'Thanks!', but what
    does 'Thanks?' mean?

    Bear with me - I took the English level in school
    that was designed for people who's parents were
    cousins (more interested in math and any flavor
    of science or tech.).

    --
    Andrew T.
    PhySci.org
     
    Andrew Thompson, Mar 10, 2008
    #11
    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. darrel
    Replies:
    3
    Views:
    690
    Scott Allen
    Aug 11, 2004
  2. Replies:
    1
    Views:
    514
    Andrew Thompson
    Oct 31, 2005
  3. Shawn
    Replies:
    2
    Views:
    1,482
    Shawn
    Dec 6, 2006
  4. DeoXMAN
    Replies:
    3
    Views:
    297
    DeoXMAN
    Apr 29, 2007
  5. yawnmoth
    Replies:
    1
    Views:
    421
    Andrew Thompson
    Aug 4, 2008
Loading...

Share This Page