{"id":3483,"date":"2016-07-16T10:04:00","date_gmt":"2016-07-16T10:04:00","guid":{"rendered":"https:\/\/www.testingdocs.com\/questions\/?p=3483"},"modified":"2024-08-09T03:21:42","modified_gmt":"2024-08-09T03:21:42","slug":"write-a-simple-java-program-to-know-the-java-version","status":"publish","type":"post","link":"https:\/\/www.testingdocs.com\/questions\/write-a-simple-java-program-to-know-the-java-version\/","title":{"rendered":"Simple Java Program to know the Java version [ 2024 ]"},"content":{"rendered":"<h2>Simple Java Program to know the Java version<\/h2>\n<p>In this tutorial, we will go through the steps involved in writing a simple Java program to display the Java version in the console window. We will use the System class. This class contains useful methods for accessing environment variables, defined properties, etc.<\/p>\n<p>For example:<\/p>\n<p><strong>System.getProperty()<\/strong> method.<\/p>\n<p>This method gets the system property indicated by the specified key.<\/p>\n<h2>Java Code Listing<\/h2>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">package com.testingdocs.sample.Questions;\r\n\/\/www.TestingDocs.com\r\npublic class SystemInfoDemo {\r\n  \r\n  public static void main(String[] args) {\r\n    System.out.println(\"Java Version = \"+ javaVersion());\r\n  }\r\n\r\n    public static String javaVersion() {\r\n        return System.getProperty(\"java.version\");\r\n    }\r\n\r\n}<\/pre>\n<p>&nbsp;<\/p>\n<h3>Run output<\/h3>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-3487 size-full\" title=\"Simple Java Program\" src=\"https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Java-Version-Program.png\" alt=\"Simple Java Program\" width=\"1732\" height=\"1015\" srcset=\"https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Java-Version-Program.png 1732w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Java-Version-Program-300x176.png 300w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Java-Version-Program-1024x600.png 1024w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Java-Version-Program-768x450.png 768w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Java-Version-Program-1536x900.png 1536w\" sizes=\"auto, (max-width: 1732px) 100vw, 1732px\" \/><\/p>\n<p>&nbsp;<\/p>\n<h2>Java Tutorials<\/h2>\n<p>Java Tutorial on this website:<\/p>\n<ul>\n<li><a href=\"https:\/\/www.testingdocs.com\/java-tutorial\/\">https:\/\/www.testingdocs.com\/java-tutorial\/<\/a><\/li>\n<\/ul>\n<p>For more information on Java, visit the official website :<\/p>\n<ul>\n<li><a href=\"https:\/\/www.oracle.com\/in\/java\/\" rel=\"noopener\">https:\/\/www.oracle.com\/in\/java\/<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Simple Java Program to know the Java version : In this tutorial, we will go through the steps involved in writing a simple Java program to display the Java version <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18],"tags":[],"class_list":["post-3483","post","type-post","status-publish","format-standard","hentry","category-java-programs","has-post-title","has-post-date","has-post-category","has-post-tag","has-post-comment","has-post-author",""],"_links":{"self":[{"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/posts\/3483","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/comments?post=3483"}],"version-history":[{"count":6,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/posts\/3483\/revisions"}],"predecessor-version":[{"id":23597,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/posts\/3483\/revisions\/23597"}],"wp:attachment":[{"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/media?parent=3483"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/categories?post=3483"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/tags?post=3483"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}