{"id":4468,"date":"2019-01-31T06:46:19","date_gmt":"2019-01-31T11:46:19","guid":{"rendered":"http:\/\/springframework.guru\/?p=4468"},"modified":"2024-10-21T07:58:40","modified_gmt":"2024-10-21T11:58:40","slug":"using-sdkman-to-manage-java-versions","status":"publish","type":"post","link":"https:\/\/springframework.guru\/using-sdkman-to-manage-java-versions\/","title":{"rendered":"How to Use SDKMAN for Managing Java Versions"},"content":{"rendered":"<h2>What Is SDKMAN?<\/h2>\n<p>As Java developers, we have to work with different versions of Java from project to project. Installing different versions by hand and setting the PATH can become a real pain at times.\u00a0<a href=\"https:\/\/sdkman.io\/\" target=\"_blank\" rel=\"noopener noreferrer\">SDKMAN<\/a>\u00a0is a command line tool that allows you to install different versions of Java, Gradle, Maven and more. SDKMAN also takes care of setting environment variables for you.<\/p>\n<h2>Installing SDKMAN<\/h2>\n<p>SDKMAN can be installed on Linux and Mac based system. To install SDKMAN enter this command at the terminal:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"java\" data-enlighter-theme=\"git\" data-enlighter-linenumbers=\"false\">$ curl -s \"https:\/\/get.sdkman.io\" | bash<\/pre>\n<p>After installation is complete close the terminal and open a new terminal.<\/p>\n<h2>Check SDKMAN Version<\/h2>\n<p>To check the current SDKMAN version enter this command at the terminal:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"java\" data-enlighter-theme=\"git\" data-enlighter-linenumbers=\"false\">$ sdk version<\/pre>\n<p>This will display the current version:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"java\" data-enlighter-theme=\"git\" data-enlighter-linenumbers=\"false\">SDKMAN 5.7.3+33<\/pre>\n<h2>Update SDKMAN<\/h2>\n<p>To update SDKMAN enter this command at the terminal:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"java\" data-enlighter-theme=\"git\" data-enlighter-linenumbers=\"false\">$ sdk update<\/pre>\n<h2>List Available Version Of Java<\/h2>\n<p>To display the versions of Java, you can install enter this command at the terminal:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"java\" data-enlighter-theme=\"git\" data-enlighter-linenumbers=\"false\">$ sdk list java<\/pre>\n<p>This will display a list of Java versions (I\u2019m not going to list them all here)<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"java\" data-enlighter-theme=\"git\" data-enlighter-linenumbers=\"false\">===================================================\n11.0.2-open\n11.0.1-open\n10.0.2-open\n10.0.1-open\n9.0.4-open\n8.0.201-oracle<\/pre>\n<h2>Install Java<\/h2>\n<p>Let\u2019s say you want to install Java 11.0.0-open enter this command at the terminal:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"java\" data-enlighter-theme=\"git\" data-enlighter-linenumbers=\"false\">$ sdk install java 11.0.2-open<\/pre>\n<p>Let\u2019s also install Java 8 using this command:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"java\" data-enlighter-theme=\"git\" data-enlighter-linenumbers=\"false\">$ sdk install java 8.0.201-oracle<\/pre>\n<h2>Display Current Java Version<\/h2>\n<p>To display the current version of Java in use enter this command at the terminal:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"java\" data-enlighter-theme=\"git\" data-enlighter-linenumbers=\"false\">$ sdk current java<\/pre>\n<p>This will display this (you may have a different version):<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"java\" data-enlighter-theme=\"git\" data-enlighter-linenumbers=\"false\">Using java version 11.0.2-open<\/pre>\n<h2>Switching Between Java Versions<\/h2>\n<p>Currently, in the example, we are using Java 11.0.2-open, and we want to switch to Java 8.0.210-oracle. To do this enter this command at the terminal:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"java\" data-enlighter-theme=\"git\" data-enlighter-linenumbers=\"false\"><span class=\"line\">$ skd default java 8.0.201-oracle<\/span><\/pre>\n<p>This will display this:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"java\" data-enlighter-theme=\"git\" data-enlighter-linenumbers=\"false\"><span class=\"line\">Default java version set to 8.0.201-oracle<\/span><\/pre>\n<h2>Uninstall a Java Version<\/h2>\n<p>Here we will uninstall Java 8. Enter this command at the terminal:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"java\" data-enlighter-theme=\"git\" data-enlighter-linenumbers=\"false\">sdk uninstall java 8.0.201-oracle<\/pre>\n<p>This will display this:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"java\" data-enlighter-theme=\"git\" data-enlighter-linenumbers=\"false\">Uninstalling java 8.0.201-oracle<\/pre>\n<h2>Conclusion<\/h2>\n<p>In the blog post, you learned how to use SDKMAN to install different versions of Java, switch between versions of Java, and uninstalling versions of Java. You can use these same methods to deal with installing tools like Maven, Gradle and so on.<\/p>\n<p><em class=\"markup--em markup--p-em\">Originally published at\u00a0<a href=\"https:\/\/www.fluentjava.com\/2019\/01\/20\/sdkman-java\/\" data-wplink-edit=\"true\">fluentjava.com<\/a><\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>What Is SDKMAN? As Java developers, we have to work with different versions of Java from project to project. Installing different versions by hand and setting the PATH can become a real pain at times.\u00a0SDKMAN\u00a0is a command line tool that allows you to install different versions of Java, Gradle, Maven and more. SDKMAN also takes [&hellip;]<a href=\"https:\/\/springframework.guru\/using-sdkman-to-manage-java-versions\/\" class=\"df-link-excerpt\">Continue reading<\/a><\/p>\n","protected":false},"author":110,"featured_media":4592,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_lmt_disableupdate":"","_lmt_disable":"","_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_uf_show_specific_survey":0,"_uf_disable_surveys":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false},"version":2}},"categories":[20],"tags":[27,210],"class_list":["post-4468","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-java","tag-java","tag-sdkman"],"jetpack_publicize_connections":[],"aioseo_notices":[],"modified_by":"jt","jetpack_sharing_enabled":true,"jetpack_featured_media_url":"https:\/\/springframework.guru\/wp-content\/uploads\/2015\/03\/Banner560x292_07web.jpg","jetpack_shortlink":"https:\/\/wp.me\/p5BZrZ-1a4","_links":{"self":[{"href":"https:\/\/springframework.guru\/wp-json\/wp\/v2\/posts\/4468"}],"collection":[{"href":"https:\/\/springframework.guru\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/springframework.guru\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/springframework.guru\/wp-json\/wp\/v2\/users\/110"}],"replies":[{"embeddable":true,"href":"https:\/\/springframework.guru\/wp-json\/wp\/v2\/comments?post=4468"}],"version-history":[{"count":10,"href":"https:\/\/springframework.guru\/wp-json\/wp\/v2\/posts\/4468\/revisions"}],"predecessor-version":[{"id":8248,"href":"https:\/\/springframework.guru\/wp-json\/wp\/v2\/posts\/4468\/revisions\/8248"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/springframework.guru\/wp-json\/wp\/v2\/media\/4592"}],"wp:attachment":[{"href":"https:\/\/springframework.guru\/wp-json\/wp\/v2\/media?parent=4468"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/springframework.guru\/wp-json\/wp\/v2\/categories?post=4468"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/springframework.guru\/wp-json\/wp\/v2\/tags?post=4468"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}