Source Code Cross Referenced for JVMInfo.java in  » Database-DBMS » db-derby-10.2 » org » apache » derby » iapi » services » info » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Database DBMS » db derby 10.2 » org.apache.derby.iapi.services.info 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:
003:           Derby - Class org.apache.derby.iapi.services.info.JVMInfo
004:
005:           Licensed to the Apache Software Foundation (ASF) under one or more
006:           contributor license agreements.  See the NOTICE file distributed with
007:           this work for additional information regarding copyright ownership.
008:           The ASF licenses this file to you under the Apache License, Version 2.0
009:           (the "License"); you may not use this file except in compliance with
010:           the License.  You may obtain a copy of the License at
011:
012:              http://www.apache.org/licenses/LICENSE-2.0
013:
014:           Unless required by applicable law or agreed to in writing, software
015:           distributed under the License is distributed on an "AS IS" BASIS,
016:           WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017:           See the License for the specific language governing permissions and
018:           limitations under the License.
019:
020:         */
021:
022:        package org.apache.derby.iapi.services.info;
023:
024:        /**
025:         What's the current JDK runtime environment.
026:         */
027:        public abstract class JVMInfo {
028:            /**
029:            	The JVM's runtime environment.
030:            	<UL>
031:            	<LI> 1 - not used was JDK 1.1
032:            	<LI> 2 - J2SE_13- JDK 1.2, 1.3
033:            	<LI> 4 - J2SE_14 - JDK 1.4.0 or 1.4.1
034:            	<LI> 5 - J2SE_142 - JDK 1.4.2
035:            	<LI> 6 - J2SE_15 - JDK 1.5
036:            	</UL>
037:             */
038:            public static final int JDK_ID;
039:
040:            public static final int J2SE_13 = 2;
041:            public static final int J2SE_14 = 4;
042:            public static final int J2SE_142 = 5;
043:            public static final int J2SE_15 = 6; // aka J2SE 5.0
044:            public static final int J2SE_16 = 7; // Java SE 6, not J2SE
045:
046:            public static final boolean J2ME;
047:
048:            /**
049:            JDBC Boolean type - Types.BIT in JDK1.1 & 1.2 & 1.3, Types.BOOLEAN in JDK1.4
050:             */
051:            public static final int JAVA_SQL_TYPES_BOOLEAN;
052:
053:            static {
054:                int id;
055:
056:                //
057:                // If the property java.specification.version is set, then try to parse
058:                // that.  Anything we don't recognize, default to Java 2 platform
059:                // because java.specification.version is a property that is introduced
060:                // in Java 2.  We hope that JVM vendors don't implement Java 1 and
061:                // set a Java 2 system property.
062:                // 
063:                // Otherwise, see if we recognize what is set in java.version.
064:                // If we don't recoginze that, or if the property is not set, assume
065:                // version 1.3.
066:                //
067:                String javaVersion;
068:                String javaSpec;
069:                boolean isJ2ME;
070:
071:                try {
072:                    javaSpec = System.getProperty("java.specification.name");
073:                } catch (SecurityException se) {
074:                    // some vms do not know about this property so they
075:                    // throw a security exception when access is restricted.
076:                    javaSpec = null;
077:                }
078:
079:                try {
080:                    javaVersion = System.getProperty(
081:                            "java.specification.version", "1.3");
082:
083:                } catch (SecurityException se) {
084:                    // some vms do not know about this property so they
085:                    // throw a security exception when access is restricted.
086:                    javaVersion = "1.3";
087:                }
088:
089:                if (javaSpec != null && javaSpec.startsWith("J2ME")) {
090:                    // IBM's WCTME 5.7 returns these values for CDC 1.0 profiles.
091:                    // "J2ME Foundation Specification"
092:                    //
093:
094:                    // Foundation 1.0 and Personal Profile 1.0 based
095:                    // upon CDC 1.0 which is JDK 1.3 based
096:                    id = J2SE_13;
097:                    isJ2ME = true;
098:                } else {
099:                    // J2SE/J2EE
100:                    isJ2ME = false;
101:
102:                    if (javaVersion.equals("1.2") || javaVersion.equals("1.3")) {
103:                        id = J2SE_13; //jdk1.3 is still Java2 platform with the same API
104:                    } else if (javaVersion.equals("1.4")) {
105:                        String vmVersion = System.getProperty("java.version",
106:                                "1.4.0");
107:
108:                        if (JVMInfo.vmCheck(vmVersion, "1.4.0")
109:                                || JVMInfo.vmCheck(vmVersion, "1.4.1"))
110:                            id = J2SE_14;
111:                        else
112:                            id = J2SE_142;
113:                    } else if (javaVersion.equals("1.5")) {
114:                        id = J2SE_15;
115:                    } else if (javaVersion.equals("1.6")) {
116:                        id = J2SE_16;
117:                    } else {
118:                        // aussme our lowest support unless the java spec
119:                        // is greater than our highest level.
120:                        id = J2SE_13;
121:
122:                        try {
123:
124:                            if (Float.valueOf(javaVersion).floatValue() > 1.4f)
125:                                id = 5;
126:                        } catch (NumberFormatException nfe) {
127:                        }
128:                    }
129:                }
130:
131:                JDK_ID = id;
132:                J2ME = isJ2ME;
133:                JAVA_SQL_TYPES_BOOLEAN = (isJ2ME || id >= J2SE_14) ? org.apache.derby.iapi.reference.JDBC30Translation.SQL_TYPES_BOOLEAN
134:                        : java.sql.Types.BIT;
135:            }
136:
137:            /**
138:            	Check the vmVersion against a speciifc value.
139:            	Sun jvms are of the form
140:             */
141:            private static boolean vmCheck(String vmVersion, String id) {
142:                return vmVersion.equals(id) || vmVersion.startsWith(id + "_");
143:            }
144:
145:            /**
146:            	Return Derby's understanding of the virtual machine's environment.
147:             */
148:            public static String derbyVMLevel() {
149:                switch (JDK_ID) {
150:                case J2SE_13:
151:                    return J2ME ? "J2ME - JDBC for CDC/FP 1.0"
152:                            : "J2SE 1.3 - JDBC 2.1";
153:                case J2SE_14:
154:                    return "J2SE 1.4 - JDBC 3.0";
155:                case J2SE_142:
156:                    return "J2SE 1.4.2 - JDBC 3.0";
157:                case J2SE_15:
158:                    return "J2SE 5.0 - JDBC 3.0";
159:                case J2SE_16:
160:                    return "Java SE 6 - JDBC 4.0";
161:                default:
162:                    return "?-?";
163:                }
164:            }
165:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.