{"id":416,"date":"2016-09-11T12:25:13","date_gmt":"2016-09-11T10:25:13","guid":{"rendered":"http:\/\/itblog.inginea.eu\/?p=416"},"modified":"2021-11-18T12:50:26","modified_gmt":"2021-11-18T11:50:26","slug":"the-simplest-way-to-define-a-singleton-in-java-correctly","status":"publish","type":"post","link":"https:\/\/ondro.inginea.eu\/index.php\/the-simplest-way-to-define-a-singleton-in-java-correctly\/","title":{"rendered":"The simplest way to define a singleton in Java correctly"},"content":{"rendered":"\n<p>A singleton pattern is probably the simplest well-known design pattern, but still people often implement it incorrectly in Java.<\/p>\n\n\n\n<!--more-->\n\n\n\n<p>The main goal of the pattern is to ensure there is a single instance of a class accessible globally before it is first needed.<\/p>\n\n\n\n<p>But wait, that could be accomplished just by a constant, right? Almost. But in reality, we often want to load the singleton lazily at the point we first need it, and we also want to ensure that it is not created multiple times in multi-threaded environments.<\/p>\n\n\n\n<p>I&#8217;ve seen crazy complex solutions <a href=\"https:\/\/community.oracle.com\/docs\/DOC-918906\">like this one<\/a> to do it correctly. I mean, they are correct, but just too complex to implement by hand without a mistake. They are applicable in any language but they don&#8217;t take into account how JVM works to simplify the solution.<\/p>\n\n\n\n<p>My point is that JVM classloaders already provide both lazy loading and thread-synchronization. Contrary to popular beliefs like that all classes are loaded at start-up or when imported by another class, they are loaded when <a href=\"http:\/\/www.programcreek.com\/2013\/01\/when-and-how-a-java-class-is-loaded-and-initialized\/\">their bytecode is executed<\/a>.<\/p>\n\n\n\n<p>Therefore it is only necessary to define a Singleton class that includes the constant &#8211; the static field will be only initialized once the class is loaded, and that would be when <code>Singleton.INSTANCE<\/code> is first accessed.<\/p>\n\n\n<pre class=\"wp-block-code lang:java decode:true\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"Java\" data-shcb-language-slug=\"java\"><span><code class=\"hljs language-java\"><span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-class\"><span class=\"hljs-keyword\">class<\/span> <span class=\"hljs-title\">ClassSingleton<\/span> <\/span>{\n\n     <span class=\"hljs-function\"><span class=\"hljs-keyword\">private<\/span> <span class=\"hljs-title\">ClassSingleton<\/span><span class=\"hljs-params\">()<\/span> <\/span>{\n        <span class=\"hljs-comment\">\/* constructor here *\/<\/span>\n     }\n\n     <span class=\"hljs-comment\">\/* instance of the singleton *\/<\/span>\n     <span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-keyword\">static<\/span> <span class=\"hljs-keyword\">final<\/span> ClassSingleton INSTANCE = <span class=\"hljs-keyword\">new<\/span> ClassSingleton();\n\n}<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Java<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">java<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>It is even simpler to use Java enum to implement the constant. Enums also bring additional advantage because enum values remain <a href=\"http:\/\/javarevisited.blogspot.cz\/2012\/07\/why-enum-singleton-are-better-in-java.html\">single even after deserialization<\/a>, whereas class instances are deserialized as new instances.<\/p>\n\n\n<pre class=\"wp-block-code lang:java decode:true\" aria-describedby=\"shcb-language-2\" data-shcb-language-name=\"Java\" data-shcb-language-slug=\"java\"><span><code class=\"hljs language-java\"><span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-keyword\">enum<\/span> EnumSingleton{\n    INSTANCE;\n\n    <span class=\"hljs-function\"><span class=\"hljs-keyword\">private<\/span> <span class=\"hljs-title\">EnumSingleton<\/span><span class=\"hljs-params\">()<\/span> <\/span>{\n        <span class=\"hljs-comment\">\/* constructor here *\/<\/span>\n    }\n\n}\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-2\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Java<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">java<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>You may access the singleton as easy as:<\/p>\n\n\n<pre class=\"wp-block-code lang:java decode:true\" aria-describedby=\"shcb-language-3\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\">System.out.println(<span class=\"hljs-string\">\"Singleton is not loaded yet...\"<\/span>); \n\n<span class=\"hljs-comment\">\/\/ the singleton's constructor is called at this time lazily<\/span>\nEnumSingleton singleton = EnumSingleton.INSTANCE; \n\nSystem.out.println(<span class=\"hljs-string\">\"Singleton is loaded now.\"<\/span>);<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-3\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>In practice, it is better to provide a getter method for the field, so that the access can be intercepted if needed later. But it is not really necessary.<\/p>\n\n\n\n<p>Note that this approach is not a new idea and it is also recommended by the <a href=\"https:\/\/www.goodreads.com\/book\/show\/29530715-effective-java\" target=\"_blank\" rel=\"nofollow noopener\">Effective Java by J. Bloch.<\/a> However, you often&nbsp;won&#8217;t find out&nbsp;that this pattern really&nbsp;loads the singleton lazily, not even in the&nbsp;Bloch&#8217;s book. There is no need to implement additional lazy loading&nbsp;and reinvent the wheel when the JVM does it for us and does it correctly even in a multi-threaded environment.<\/p>\n\n\n\n<p>Therefore the core message from me is: there is no need to ensure additional lazy loading and synchronized access to the constructor. The <strong>JVM does it for us and does it correctly<\/strong>!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A singleton pattern is probably the simplest well-known design pattern, but still people often implement it incorrectly in Java.<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","footnotes":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false}}},"categories":[64],"tags":[14,152,150],"series":[],"class_list":["post-416","post","type-post","status-publish","format-standard","hentry","category-java","tag-jvm","tag-patterns","tag-singleton"],"jetpack_publicize_connections":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.9 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>The simplest way to define a singleton in Java correctly - .Lost in Coding<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/ondro.inginea.eu\/index.php\/the-simplest-way-to-define-a-singleton-in-java-correctly\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"The simplest way to define a singleton in Java correctly - .Lost in Coding\" \/>\n<meta property=\"og:description\" content=\"A singleton pattern is probably the simplest well-known design pattern, but still people often implement it incorrectly in Java.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/ondro.inginea.eu\/index.php\/the-simplest-way-to-define-a-singleton-in-java-correctly\/\" \/>\n<meta property=\"og:site_name\" content=\".Lost in Coding\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/ondrej.mihalyi\" \/>\n<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/ondrej.mihalyi\" \/>\n<meta property=\"article:published_time\" content=\"2016-09-11T10:25:13+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-11-18T11:50:26+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/i0.wp.com\/ondro.inginea.eu\/wp-content\/uploads\/2021\/09\/duke-CloudSurf-small-e1637277171314.png?fit=300%2C202&ssl=1\" \/>\n\t<meta property=\"og:image:width\" content=\"300\" \/>\n\t<meta property=\"og:image:height\" content=\"202\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Ondro Mih\u00e1lyi\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@https:\/\/twitter.com\/OndroMih\" \/>\n<meta name=\"twitter:site\" content=\"@OndroMih\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Ondro Mih\u00e1lyi\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/ondro.inginea.eu\/index.php\/the-simplest-way-to-define-a-singleton-in-java-correctly\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/ondro.inginea.eu\/index.php\/the-simplest-way-to-define-a-singleton-in-java-correctly\/\"},\"author\":{\"name\":\"Ondro Mih\u00e1lyi\",\"@id\":\"https:\/\/ondro.inginea.eu\/#\/schema\/person\/07ac1158ec74720744f7146572215616\"},\"headline\":\"The simplest way to define a singleton in Java correctly\",\"datePublished\":\"2016-09-11T10:25:13+00:00\",\"dateModified\":\"2021-11-18T11:50:26+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/ondro.inginea.eu\/index.php\/the-simplest-way-to-define-a-singleton-in-java-correctly\/\"},\"wordCount\":401,\"commentCount\":3,\"publisher\":{\"@id\":\"https:\/\/ondro.inginea.eu\/#\/schema\/person\/07ac1158ec74720744f7146572215616\"},\"keywords\":[\"JVM\",\"patterns\",\"singleton\"],\"articleSection\":[\"Java\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/ondro.inginea.eu\/index.php\/the-simplest-way-to-define-a-singleton-in-java-correctly\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/ondro.inginea.eu\/index.php\/the-simplest-way-to-define-a-singleton-in-java-correctly\/\",\"url\":\"https:\/\/ondro.inginea.eu\/index.php\/the-simplest-way-to-define-a-singleton-in-java-correctly\/\",\"name\":\"The simplest way to define a singleton in Java correctly - .Lost in Coding\",\"isPartOf\":{\"@id\":\"https:\/\/ondro.inginea.eu\/#website\"},\"datePublished\":\"2016-09-11T10:25:13+00:00\",\"dateModified\":\"2021-11-18T11:50:26+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/ondro.inginea.eu\/index.php\/the-simplest-way-to-define-a-singleton-in-java-correctly\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/ondro.inginea.eu\/index.php\/the-simplest-way-to-define-a-singleton-in-java-correctly\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/ondro.inginea.eu\/index.php\/the-simplest-way-to-define-a-singleton-in-java-correctly\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/ondro.inginea.eu\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"The simplest way to define a singleton in Java correctly\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/ondro.inginea.eu\/#website\",\"url\":\"https:\/\/ondro.inginea.eu\/\",\"name\":\".Lost in Coding\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/ondro.inginea.eu\/#\/schema\/person\/07ac1158ec74720744f7146572215616\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/ondro.inginea.eu\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/ondro.inginea.eu\/#\/schema\/person\/07ac1158ec74720744f7146572215616\",\"name\":\"Ondro Mih\u00e1lyi\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/ondro.inginea.eu\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/i2.wp.com\/ondro.inginea.eu\/wp-content\/uploads\/2017\/08\/fotoOMsquare3x300.jpg?fit=300%2C300&ssl=1\",\"contentUrl\":\"https:\/\/i2.wp.com\/ondro.inginea.eu\/wp-content\/uploads\/2017\/08\/fotoOMsquare3x300.jpg?fit=300%2C300&ssl=1\",\"width\":300,\"height\":300,\"caption\":\"Ondro Mih\u00e1lyi\"},\"logo\":{\"@id\":\"https:\/\/ondro.inginea.eu\/#\/schema\/person\/image\/\"},\"description\":\"Ondro is a software developer and consultant specializing in combining standard and proven tools to solve new and challenging problems. He's been developing in Java for over 10 years. He\u2019s worked for clients like Payara, LottoLand, Uniqa and others. He has co-founded OmniFish, where he works as a director and Jakarta EE expert. He\u2019s passionate about helping his clients and the wider Java community with their projects based on Jakarta EE and similar technologies. As an experienced Java developer and instructor, he's helped companies build and educate their development teams and improve their development processes. He's a core member of several opensource projects and Jakarta EE specification projects. He\u2019s a frequent conference speaker, leader of the Czech JUG and a Java Champion. Ondro is a regular conference speaker at international conferences. Since 2016, he's presented at the following conferences: \u2022 FOSDEM, Brussels, Belgium 2023) \u2022 JChampionsConf, Online (year 2023) \u2022 EclipseCon, Germany (year 2022) \u2022 GeeCon, Prague, Czechia (years 2016, 2019, 2022) \u2022 JavaLand, Bruehl, Germany (years 2018, 2021) \u2022 JFokus, Stockholm, Sweden (year 2019) \u2022 Devops Con, Munich, Germany (year 2019) \u2022 Oracle CodeOne, San Francisco, USA (years 2018, 2019) \u2022 Devoxx, Antwerp, Belgium (year 2018) \u2022 JPrime, Sofia, Bulgaria (years 2017, 2018) \u2022 Java2Days, Sofia, Bulgaria (years 2016, 2018) \u2022 EclipseCon, France (year 2018) \u2022 JavaOne, San Francisco, USA (years 2016, 2017) \u2022 Oracle Code, Prague, Czechia (year 2017) \u2022 Devoxx, London, UK (year 2017) \u2022 GeeCon, Krakow, Poland (year 2017) \u2022 W-JAX, Munich, Germany (years 2016, 2017) \u2022 Bed-Con, Berlin, Germany (year 2017) \u2022 Oredev, Malmo, Sweden (year 2017) \u2022 Devoxx, Casablanca, Morocco (year 2017) \u2022 Java Developer Days, Krakow, Poland (year 2016)\",\"sameAs\":[\"https:\/\/www.facebook.com\/ondrej.mihalyi\",\"https:\/\/cz.linkedin.com\/in\/mihalyiondrej\",\"https:\/\/twitter.com\/https:\/\/twitter.com\/OndroMih\"],\"url\":\"https:\/\/ondro.inginea.eu\/index.php\/author\/ondrejm\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"The simplest way to define a singleton in Java correctly - .Lost in Coding","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/ondro.inginea.eu\/index.php\/the-simplest-way-to-define-a-singleton-in-java-correctly\/","og_locale":"en_US","og_type":"article","og_title":"The simplest way to define a singleton in Java correctly - .Lost in Coding","og_description":"A singleton pattern is probably the simplest well-known design pattern, but still people often implement it incorrectly in Java.","og_url":"https:\/\/ondro.inginea.eu\/index.php\/the-simplest-way-to-define-a-singleton-in-java-correctly\/","og_site_name":".Lost in Coding","article_publisher":"https:\/\/www.facebook.com\/ondrej.mihalyi","article_author":"https:\/\/www.facebook.com\/ondrej.mihalyi","article_published_time":"2016-09-11T10:25:13+00:00","article_modified_time":"2021-11-18T11:50:26+00:00","og_image":[{"width":300,"height":202,"url":"https:\/\/i0.wp.com\/ondro.inginea.eu\/wp-content\/uploads\/2021\/09\/duke-CloudSurf-small-e1637277171314.png?fit=300%2C202&ssl=1","type":"image\/png"}],"author":"Ondro Mih\u00e1lyi","twitter_card":"summary_large_image","twitter_creator":"@https:\/\/twitter.com\/OndroMih","twitter_site":"@OndroMih","twitter_misc":{"Written by":"Ondro Mih\u00e1lyi","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/ondro.inginea.eu\/index.php\/the-simplest-way-to-define-a-singleton-in-java-correctly\/#article","isPartOf":{"@id":"https:\/\/ondro.inginea.eu\/index.php\/the-simplest-way-to-define-a-singleton-in-java-correctly\/"},"author":{"name":"Ondro Mih\u00e1lyi","@id":"https:\/\/ondro.inginea.eu\/#\/schema\/person\/07ac1158ec74720744f7146572215616"},"headline":"The simplest way to define a singleton in Java correctly","datePublished":"2016-09-11T10:25:13+00:00","dateModified":"2021-11-18T11:50:26+00:00","mainEntityOfPage":{"@id":"https:\/\/ondro.inginea.eu\/index.php\/the-simplest-way-to-define-a-singleton-in-java-correctly\/"},"wordCount":401,"commentCount":3,"publisher":{"@id":"https:\/\/ondro.inginea.eu\/#\/schema\/person\/07ac1158ec74720744f7146572215616"},"keywords":["JVM","patterns","singleton"],"articleSection":["Java"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/ondro.inginea.eu\/index.php\/the-simplest-way-to-define-a-singleton-in-java-correctly\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/ondro.inginea.eu\/index.php\/the-simplest-way-to-define-a-singleton-in-java-correctly\/","url":"https:\/\/ondro.inginea.eu\/index.php\/the-simplest-way-to-define-a-singleton-in-java-correctly\/","name":"The simplest way to define a singleton in Java correctly - .Lost in Coding","isPartOf":{"@id":"https:\/\/ondro.inginea.eu\/#website"},"datePublished":"2016-09-11T10:25:13+00:00","dateModified":"2021-11-18T11:50:26+00:00","breadcrumb":{"@id":"https:\/\/ondro.inginea.eu\/index.php\/the-simplest-way-to-define-a-singleton-in-java-correctly\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/ondro.inginea.eu\/index.php\/the-simplest-way-to-define-a-singleton-in-java-correctly\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/ondro.inginea.eu\/index.php\/the-simplest-way-to-define-a-singleton-in-java-correctly\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/ondro.inginea.eu\/"},{"@type":"ListItem","position":2,"name":"The simplest way to define a singleton in Java correctly"}]},{"@type":"WebSite","@id":"https:\/\/ondro.inginea.eu\/#website","url":"https:\/\/ondro.inginea.eu\/","name":".Lost in Coding","description":"","publisher":{"@id":"https:\/\/ondro.inginea.eu\/#\/schema\/person\/07ac1158ec74720744f7146572215616"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/ondro.inginea.eu\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/ondro.inginea.eu\/#\/schema\/person\/07ac1158ec74720744f7146572215616","name":"Ondro Mih\u00e1lyi","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/ondro.inginea.eu\/#\/schema\/person\/image\/","url":"https:\/\/i2.wp.com\/ondro.inginea.eu\/wp-content\/uploads\/2017\/08\/fotoOMsquare3x300.jpg?fit=300%2C300&ssl=1","contentUrl":"https:\/\/i2.wp.com\/ondro.inginea.eu\/wp-content\/uploads\/2017\/08\/fotoOMsquare3x300.jpg?fit=300%2C300&ssl=1","width":300,"height":300,"caption":"Ondro Mih\u00e1lyi"},"logo":{"@id":"https:\/\/ondro.inginea.eu\/#\/schema\/person\/image\/"},"description":"Ondro is a software developer and consultant specializing in combining standard and proven tools to solve new and challenging problems. He's been developing in Java for over 10 years. He\u2019s worked for clients like Payara, LottoLand, Uniqa and others. He has co-founded OmniFish, where he works as a director and Jakarta EE expert. He\u2019s passionate about helping his clients and the wider Java community with their projects based on Jakarta EE and similar technologies. As an experienced Java developer and instructor, he's helped companies build and educate their development teams and improve their development processes. He's a core member of several opensource projects and Jakarta EE specification projects. He\u2019s a frequent conference speaker, leader of the Czech JUG and a Java Champion. Ondro is a regular conference speaker at international conferences. Since 2016, he's presented at the following conferences: \u2022 FOSDEM, Brussels, Belgium 2023) \u2022 JChampionsConf, Online (year 2023) \u2022 EclipseCon, Germany (year 2022) \u2022 GeeCon, Prague, Czechia (years 2016, 2019, 2022) \u2022 JavaLand, Bruehl, Germany (years 2018, 2021) \u2022 JFokus, Stockholm, Sweden (year 2019) \u2022 Devops Con, Munich, Germany (year 2019) \u2022 Oracle CodeOne, San Francisco, USA (years 2018, 2019) \u2022 Devoxx, Antwerp, Belgium (year 2018) \u2022 JPrime, Sofia, Bulgaria (years 2017, 2018) \u2022 Java2Days, Sofia, Bulgaria (years 2016, 2018) \u2022 EclipseCon, France (year 2018) \u2022 JavaOne, San Francisco, USA (years 2016, 2017) \u2022 Oracle Code, Prague, Czechia (year 2017) \u2022 Devoxx, London, UK (year 2017) \u2022 GeeCon, Krakow, Poland (year 2017) \u2022 W-JAX, Munich, Germany (years 2016, 2017) \u2022 Bed-Con, Berlin, Germany (year 2017) \u2022 Oredev, Malmo, Sweden (year 2017) \u2022 Devoxx, Casablanca, Morocco (year 2017) \u2022 Java Developer Days, Krakow, Poland (year 2016)","sameAs":["https:\/\/www.facebook.com\/ondrej.mihalyi","https:\/\/cz.linkedin.com\/in\/mihalyiondrej","https:\/\/twitter.com\/https:\/\/twitter.com\/OndroMih"],"url":"https:\/\/ondro.inginea.eu\/index.php\/author\/ondrejm\/"}]}},"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p6wlb6-6I","jetpack-related-posts":[{"id":33,"url":"https:\/\/ondro.inginea.eu\/index.php\/decrease-your-java-ide-lagging-by-fine-tuning-jvm-garbage-collector\/","url_meta":{"origin":416,"position":0},"title":"Decrease your Java IDE lagging by fine tuning JVM Garbage Collector","author":"Ondro Mih\u00e1lyi","date":"5 March, 2015","format":false,"excerpt":"Ever wondered why Eclipse\/Netbeans keeps pausing for a while every now an then? Especially right at the time when you want to show something in the code to your dear colleages? It feelt embarrassing and awkward, didn't it? I found out that most of the time the IDE pauses because\u2026","rel":"","context":"In &quot;Java&quot;","block_context":{"text":"Java","link":"https:\/\/ondro.inginea.eu\/index.php\/category\/java\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":533,"url":"https:\/\/ondro.inginea.eu\/index.php\/using-hotswapagent-to-speed-up-development\/","url_meta":{"origin":416,"position":1},"title":"Using HotswapAgent to speed up development","author":"Ondro Mih\u00e1lyi","date":"20 October, 2017","format":false,"excerpt":"As a Java EE developer, I sometimes envy how fast it's possible to see the result of a code change in a running application with interpreted languages like PHP or JavaScript. With Java, it's always necessary to rebuild the source code in a bytecode, which can be then safely updated\u2026","rel":"","context":"In &quot;Configuration&quot;","block_context":{"text":"Configuration","link":"https:\/\/ondro.inginea.eu\/index.php\/category\/config\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/ondro.inginea.eu\/wp-content\/uploads\/2017\/09\/Screenshot-from-DCEVM.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":769,"url":"https:\/\/ondro.inginea.eu\/index.php\/new-features-in-java-versions-since-java-8\/","url_meta":{"origin":416,"position":2},"title":"New features between Java 8 and Java 19","author":"Ondro Mih\u00e1lyi","date":"8 October, 2022","format":false,"excerpt":"Since version 9, Java has new features every 6 months and it's very hard to keep track of these new changes. Most of the information on the internet describes changes between the last 2 Java versions. However, if you're in a similar situation as me, you're not using one of\u2026","rel":"","context":"In &quot;Java&quot;","block_context":{"text":"Java","link":"https:\/\/ondro.inginea.eu\/index.php\/category\/java\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/ondro.inginea.eu\/wp-content\/uploads\/2021\/09\/duke-CloudSurf-small-e1637277171314.png?fit=300%2C202&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":476,"url":"https:\/\/ondro.inginea.eu\/index.php\/what-people-expect-to-see-at-the-conferences\/","url_meta":{"origin":416,"position":3},"title":"What people expect to see at the conferences","author":"Ondro Mih\u00e1lyi","date":"24 January, 2017","format":false,"excerpt":"As a public presenter, I always wonder what kind of presentation should I submit for tech conferences. Knowing what people want to hear about is always important to submit a good talk, and to give a good presentation once the talk is accepted by the conference. Here are some insights\u2026","rel":"","context":"In &quot;Events &amp; Conferences&quot;","block_context":{"text":"Events &amp; Conferences","link":"https:\/\/ondro.inginea.eu\/index.php\/category\/events-conferences\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":13,"url":"https:\/\/ondro.inginea.eu\/index.php\/impressions-from-geecon-in-prague-day-2\/","url_meta":{"origin":416,"position":4},"title":"Impressions from Geecon in Prague &#8211; Day 2","author":"Ondro Mih\u00e1lyi","date":"15 November, 2014","format":false,"excerpt":"The day 2 started earlier than the day before. A bit too early for me. While hurrying to catch the beginning of the first presentation, however, a stranger with a big suitcase passed by me in an even greater hurry, a bit confused about which way to take. I grinned\u2026","rel":"","context":"In &quot;Events &amp; Conferences&quot;","block_context":{"text":"Events &amp; Conferences","link":"https:\/\/ondro.inginea.eu\/index.php\/category\/events-conferences\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":209,"url":"https:\/\/ondro.inginea.eu\/index.php\/mvc-1-0-in-java-ee-8-getting-started-using-facelets\/","url_meta":{"origin":416,"position":5},"title":"MVC 1.0 in Java EE 8: Getting started using facelets","author":"Ondro Mih\u00e1lyi","date":"19 January, 2016","format":false,"excerpt":"MVC 1.0 is an action-based Model-View-Controller web framework, which will be a part of future Java EE 8. It will live side by side with component-based JSF framework and will provide an alternative for building HTML+javascript oriented applications with full control over URLs. This post summarizes what needs to be\u2026","rel":"","context":"In &quot;Jakarta EE&quot;","block_context":{"text":"Jakarta EE","link":"https:\/\/ondro.inginea.eu\/index.php\/category\/java\/jakarta-ee\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"https:\/\/ondro.inginea.eu\/index.php\/wp-json\/wp\/v2\/posts\/416"}],"collection":[{"href":"https:\/\/ondro.inginea.eu\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ondro.inginea.eu\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ondro.inginea.eu\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/ondro.inginea.eu\/index.php\/wp-json\/wp\/v2\/comments?post=416"}],"version-history":[{"count":11,"href":"https:\/\/ondro.inginea.eu\/index.php\/wp-json\/wp\/v2\/posts\/416\/revisions"}],"predecessor-version":[{"id":963,"href":"https:\/\/ondro.inginea.eu\/index.php\/wp-json\/wp\/v2\/posts\/416\/revisions\/963"}],"wp:attachment":[{"href":"https:\/\/ondro.inginea.eu\/index.php\/wp-json\/wp\/v2\/media?parent=416"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ondro.inginea.eu\/index.php\/wp-json\/wp\/v2\/categories?post=416"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ondro.inginea.eu\/index.php\/wp-json\/wp\/v2\/tags?post=416"},{"taxonomy":"series","embeddable":true,"href":"https:\/\/ondro.inginea.eu\/index.php\/wp-json\/wp\/v2\/series?post=416"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}