Getting the Version of Java

Is there a way for a jar to have both the java 5 and 6 librarys, and then detect which one the machine has and run the jar using a specific library?
[155 byte] By [blackmagea] at [2007-11-27 8:34:29]
# 1
You should be able to jar up multiple classes that were compiled to different target versions, but I have no idea why you'd want to do what you're suggesting.
Djaunla at 2007-7-12 20:30:45 > top of Java-index,Java Essentials,Java Programming...
# 2
If you want it to run on a 5 or 6 jre, then compile the code to 5. If it has to be compiled to 6, then you'll have to require a 6 jre to run it.
hunter9000a at 2007-7-12 20:30:45 > top of Java-index,Java Essentials,Java Programming...
# 3

Say you have different versions in different jars, and a separate launcher jar.

You examine:

System.getProperty("java.version")

or

System.getProperty("java.specification.version")

or

System.getProperty("java.class.version")

etc...

Based on that result, you use URLClassLoader to load from the appropriate jar. Then you roll back on your heels because you straddle the earth like a titan.

Hippolytea at 2007-7-12 20:30:45 > top of Java-index,Java Essentials,Java Programming...
# 4
Nice shiny silver star Hippolyte.
Djaunla at 2007-7-12 20:30:45 > top of Java-index,Java Essentials,Java Programming...
# 5
Posted too fast, shoud have read better, sorry :-/
Pucea at 2007-7-12 20:30:45 > top of Java-index,Java Essentials,Java Programming...
# 6
> Nice shiny silver star Hippolyte.I hates it. This is my last full-time day as Hippolyte. Next week I will return in a more robust form.
Hippolytea at 2007-7-12 20:30:45 > top of Java-index,Java Essentials,Java Programming...
# 7
> > Nice shiny silver star Hippolyte.> > I hates it. This is my last full-time day as> Hippolyte. Next week I will return in a more robust> form.You should go into business leveling up people's stars for cash. ;-)
hunter9000a at 2007-7-12 20:30:45 > top of Java-index,Java Essentials,Java Programming...
# 8

> > > Nice shiny silver star Hippolyte.

> >

> > I hates it. This is my last full-time day as

> > Hippolyte. Next week I will return in a more

> robust

> > form.

>

> You should go into business leveling up people's

> stars for cash. ;-)

I think I just read an article about "Gold Farming" on the New York Times website. They say there are 100,000 workers doing that in sweatshops in China.

Hippolytea at 2007-7-12 20:30:45 > top of Java-index,Java Essentials,Java Programming...
# 9

> > > > Nice shiny silver star Hippolyte.

> > >

> > > I hates it. This is my last full-time day as

> > > Hippolyte. Next week I will return in a more

> > robust

> > > form.

> >

> > You should go into business leveling up people's

> > stars for cash. ;-)

>

> I think I just read an article about "Gold Farming"

> on the New York Times website. They say there are

> 100,000 workers doing that in sweatshops in China.

saw a documentary about it on TV last month. Sad isn't it, that people would pay real money to have others play videogames for them (except for test/eval purposes of course)?

jwentinga at 2007-7-12 20:30:45 > top of Java-index,Java Essentials,Java Programming...