Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / March 2008

Tip: Looking for answers? Try searching our database.

Determining which versions of java a program will run on?

Thread view: 
travel2light - 08 Mar 2008 16:26 GMT
Is there a way to find this out? Thanks for any advice.

Michael
Jeff Higgins - 08 Mar 2008 16:52 GMT
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>
Andrew Thompson - 08 Mar 2008 23:35 GMT
> 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
travel2light - 09 Mar 2008 00:27 GMT
> > 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?
>
[quoted text clipped - 5 lines]
> 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
Andrew Thompson - 09 Mar 2008 02:10 GMT
...
> > 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
Kenneth P. Turvey - 10 Mar 2008 01:41 GMT
[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.

Signature

Kenneth P. Turvey <kt-usenet@squeakydolphin.com>

Andrew Thompson - 10 Mar 2008 01:58 GMT
On Mar 10, 10:41 am, "Kenneth P. Turvey" <kt-
use...@squeakydolphin.com> 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
Kenneth P. Turvey - 10 Mar 2008 08:04 GMT
> 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?

Signature

Kenneth P. Turvey <kt-usenet@squeakydolphin.com>

Andrew Thompson - 10 Mar 2008 10:04 GMT
On Mar 10, 6:04 pm, "Kenneth P. Turvey" <kt-use...@squeakydolphin.com>
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
Roedy Green - 08 Mar 2008 23:57 GMT
On Sat, 8 Mar 2008 08:26:13 -0800 (PST), travel2light
<everything2light@yahoo.co.uk> wrote, quoted or indirectly quoted
someone who said :

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

see http://mindprod.com/project/jdkversion.html
--

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
Arne Vajhøj - 09 Mar 2008 05:30 GMT
> 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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.