Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (525)
Games in Android Showcase (127)
games submitted by our members
Games in WIP (594)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  how to know what current jvm version is running  (Read 2314 times)
0 Members and 1 Guest are viewing this topic.
Offline pepe

Junior Devvie




Nothing unreal exists


« Posted 2002-10-22 14:37:15 »


String version = System.getProperty("java.specification.version");

This method will work in every versions of jre specs, so you can test this with 1.1 applets without problem.
you can get an eye here for more keys to use:
http://java.sun.com/j2se/1.4/docs/api/java/lang/System.html#getProperties()

Home page: http://frederic.barachant.com
------------------------------------------------------
GoSub: java2D gamechmark http://frederic.barachant.com/GoSub/GoSub.jnlp
Offline Jeff

JGO Coder




Got any cats?


« Reply #1 - Posted 2002-10-23 22:14:43 »

Someone asked this question in the Newbies section so i posted
a bit mreo code.  The main addtion to pepe's post is how to
load your real main class froma version checking shell by
reflection.

This is necessary if you want to handle garcefuilly running under an earlier runtime that might not have available all the system classes
your real main links to.  It delays the resolution of those linkls until after you've checked and approved the version.


Got a question about Java and game programming?  Just new to the Java Game Development Community?  Try my FAQ.  Its likely you'll learn something!

http://wiki.java.net/bin/view/Games/JeffFAQ
Offline pepe

Junior Devvie




Nothing unreal exists


« Reply #2 - Posted 2002-10-24 10:54:19 »

Thanks for the added features, Jeff.
by the way, here is the link to the original question and your code:
http://www.java-gaming.org/cgi-bin/JGOForums/YaBB.cgi?board=newbies;action=display;num=1035234634

Home page: http://frederic.barachant.com
------------------------------------------------------
GoSub: java2D gamechmark http://frederic.barachant.com/GoSub/GoSub.jnlp
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Mac_Systems

Junior Devvie




I love my Java


« Reply #3 - Posted 2003-07-31 07:50:27 »

I have some Code written last month for that.
Simply Test the actual Version against the given one.

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
    /**
     * Test if Java Version equals or is higher on System.<br>
     *
     * @param javaVersion The Version to Test against.
     * @return true/false
     */

    public static boolean isJavaVersionHigherOrEqualInstalled ( double
            javaVersion )
    {
        if ( javaVersion >= 1.0d )
        {
            try
            {
                String installedVersionString = JavaInfo.getJavaVersion () ;
                // ersten punkt suchen ....
                int index = installedVersionString.indexOf ( "." ) ;
                index += 2 ;
                // ben?«Ótigte infos ausschneiden...
                installedVersionString = installedVersionString.substring ( 0 ,
                        index ) ;
                //umwandeln in double objekt
                Double temp = new Double ( installedVersionString ) ;
                // umwandeln in primitive
                double installedVersion = temp.doubleValue () ;
                System.out.println ( "Installed Version:" + installedVersion ) ;
                System.out.println ( "Installed Version die da sein muss:" +
                                     javaVersion ) ;
                //und vergleichen ?
                if ( installedVersion >= javaVersion )
                {
                    return true ;
                }
                return false ;

            }
            catch ( NumberFormatException ex )
            {
                ex.printStackTrace () ;
                return false ;
            }
        }
        return false ;
    }



The Network is the Music
http://www.mac-systems.de
Offline AndersDahlberg

Junior Devvie





« Reply #4 - Posted 2003-07-31 17:59:24 »

hmm, any reason java versioning doesn't work (I haven't tested this, so I'm not sure if this is how it's supposed to work...)?

1  
2  
3  
Package javaVersion = java.lang.Package.getpackage("java.lang"); 
// Any core j2se package should work I guess?
boolean ok = javaVersion.isCompatibleWith("1.4.2");
Offline Mac_Systems

Junior Devvie




I love my Java


« Reply #5 - Posted 2003-07-31 18:25:23 »

Hmm,

interresting, did not know  Cool that ! But it is not
specified how the String have to look like (?? my English).

- Jens


The Network is the Music
http://www.mac-systems.de
Offline AndersDahlberg

Junior Devvie





« Reply #6 - Posted 2003-07-31 20:06:38 »

http://java.sun.com/j2se/1.4.2/docs/guide/versioning/spec/versioningTOC.html

That should give you a lot of information Smiley

It's actually not crystal clear if my suggestion will actually work (information provided be the link seems to contradict the api documentation of isCompatibleWith??)

EDIT: I believe the syntax of the version string is
<major>.<minor>[.<"bugfix">]

i.e. microsoft vm isCompatibleWith("1.1") should return true - but
isCompatibleWith("1.1.9") should return false (replace 9 with the actual latest bug fix number of the ms vm +1 )

And the current (1.4.2) should return true when given isCompatibleWith("1.4") (or 1.4.2, 1.4.1, 1.3.1 etc etc Smiley
Offline Mac_Systems

Junior Devvie




I love my Java


« Reply #7 - Posted 2003-07-31 20:48:25 »

I Have some book the Java Lang. Spec. Issue 3.
There were said that if you use the getPropertie
Method from util Package will return Strings in this
this format:

Major.Minor.BugFix

seems to be the Same format  Kiss as you posted

Interresting to know, so my code ma be a bit "oversized" but should work also on Blackdown VM
or other.
But, this is of course the shortest solution, i will fix that in my Project.

- Jens



The Network is the Music
http://www.mac-systems.de
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

toopeicgaming1999 (71 views)
2014-11-26 15:22:04

toopeicgaming1999 (60 views)
2014-11-26 15:20:36

toopeicgaming1999 (14 views)
2014-11-26 15:20:08

SHC (27 views)
2014-11-25 12:00:59

SHC (25 views)
2014-11-25 11:53:45

Norakomi (31 views)
2014-11-25 11:26:43

Gibbo3771 (25 views)
2014-11-24 19:59:16

trollwarrior1 (38 views)
2014-11-22 12:13:56

xFryIx (77 views)
2014-11-13 12:34:49

digdugdiggy (55 views)
2014-11-12 21:11:50
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!