{"id":5588,"date":"2021-01-05T22:41:24","date_gmt":"2021-01-05T23:11:24","guid":{"rendered":"https:\/\/ultering.com\/it4us\/?p=5588"},"modified":"2021-01-21T15:31:53","modified_gmt":"2021-01-21T16:01:53","slug":"handling-java-installation-on-debian-ubuntu-eclipse-fails-with-exit-code","status":"publish","type":"post","link":"https:\/\/ultering.com\/it4us\/?p=5588","title":{"rendered":"Java: Handling Java Installation on Debian\/Ubuntu &#8211; Eclipse fails with exit code"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_83 counter-hierarchy ez-toc-counter ez-toc-white ez-toc-container-direction\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-6a28fc62eae2d\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-6a28fc62eae2d\" checked aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/ultering.com\/it4us\/?p=5588\/#Scenario\" >Scenario<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/ultering.com\/it4us\/?p=5588\/#THE_FLASH_SOLUTION\" >THE FLASH SOLUTION<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/ultering.com\/it4us\/?p=5588\/#How_to_handle_javas_environment\" >How to handle java&#8217;s environment?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/ultering.com\/it4us\/?p=5588\/#DISCOVERING_YOUR_ENVIRONMENT\" >DISCOVERING YOUR ENVIRONMENT<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/ultering.com\/it4us\/?p=5588\/#INSTALLING_FRESH_JAVA\" >INSTALLING FRESH JAVA<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/ultering.com\/it4us\/?p=5588\/#Using_apt_apt-get_command\" >Using apt (apt-get) command<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/ultering.com\/it4us\/?p=5588\/#Manual_installation\" >Manual installation<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/ultering.com\/it4us\/?p=5588\/#Framework_With_Installer\" >Framework With Installer<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/ultering.com\/it4us\/?p=5588\/#SET_AND_RESET_JAVA_ENV\" >SET AND RESET JAVA ENV<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/ultering.com\/it4us\/?p=5588\/#SWITCHING_THE_ENVIRONMENTS_JAVA_VERSION\" >#SWITCHING THE ENVIRONMENT&#8217;S JAVA VERSION<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-11\" href=\"https:\/\/ultering.com\/it4us\/?p=5588\/#MANUAL_SWITCH\" >#MANUAL SWITCH<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-12\" href=\"https:\/\/ultering.com\/it4us\/?p=5588\/#WHEN_THINGS_DONT_HAPPEN_AND_HOW_TO_FIX\" >WHEN THINGS DON&#8217;T HAPPEN AND HOW TO FIX<\/a><ul class='ez-toc-list-level-4' ><li class='ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-13\" href=\"https:\/\/ultering.com\/it4us\/?p=5588\/#NOTE\" >NOTE:<\/a><\/li><\/ul><\/li><\/ul><\/li><\/ul><\/nav><\/div>\n<h2><span class=\"ez-toc-section\" id=\"Scenario\"><\/span>Scenario<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Suppose that you try to start an Eclipse installation, and it fails returning exit code 8, 13, etc. , something like &#8220;<em>java terminated exit code 8<\/em>&#8220;.<\/p>\n<p>This is usually caused due to the version of Java used by the environment that it is incompatible with the version of the Eclipse installation.<\/p>\n<p>Another situation comes to happen when the available java is that you wish.<\/p>\n<p>&nbsp;<\/p>\n<h2><span class=\"ez-toc-section\" id=\"THE_FLASH_SOLUTION\"><\/span>THE FLASH SOLUTION<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>If you like things very fast, here is the summary (or follow below the detailed information):<\/p>\n<p>&#8211; installs or fix cmds:<br \/>\nsudo apt-get install default-jdk<br \/>\nsudo update-alternatives &#8211;config java<br \/>\nsudo apt-get purge default-jdk<\/p>\n<p>&#8211; reboot if necessary<\/p>\n<p>&#8211; check with:<br \/>\nsudo apt-get install default-jdk<br \/>\njava -version<br \/>\nwhereis java<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<h2><span class=\"ez-toc-section\" id=\"How_to_handle_javas_environment\"><\/span>How to handle java&#8217;s environment?<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><span data-preserver-spaces=\"true\">We shall think about two situations.<\/span><\/p>\n<p><span data-preserver-spaces=\"true\">We may have no java installed or not.<\/span><\/p>\n<p>If you have already install java, go to &#8220;SET AND RESET JAVA ENV&#8221; section.<\/p>\n<p>&nbsp;<\/p>\n<h2><span class=\"ez-toc-section\" id=\"DISCOVERING_YOUR_ENVIRONMENT\"><\/span>DISCOVERING YOUR ENVIRONMENT<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Type:<br \/>\n<em><br \/>\njava -version<\/em><\/p>\n<p>Check if there are other alternatives:<br \/>\n<em><br \/>\nsudo update-alternatives &#8211;config java<\/em><\/p>\n<pre class=\"\">There is only one alternative in link group java (providing \/usr\/bin\/java): \/usr\/lib\/jvm\/java-11-openjdk-amd64\/bin\/java\r\nNothing to configure.\r\nupdate-alternatives: warning: forcing reinstallation of alternative \/usr\/lib\/jvm\/java-11-openjdk-amd64\/bin\/java because link group java is broken\r\nupdate-alternatives: warning: not replacing \/usr\/bin\/java with a link<\/pre>\n<p>This output shows just one option, but If there are more options will return the a list.<\/p>\n<p>&nbsp;<\/p>\n<h2><span class=\"ez-toc-section\" id=\"INSTALLING_FRESH_JAVA\"><\/span><span data-preserver-spaces=\"true\">INSTALLING FRESH JAVA<\/span><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><span data-preserver-spaces=\"true\">At least three options:<\/span><\/p>\n<ol>\n<li>Using apt, the default installation method on Debian distributions.<\/li>\n<li>Manually, by download of a tar file.<\/li>\n<li><span data-preserver-spaces=\"true\">If a framework like Eclipse, you may download it with an installer.<\/span><\/li>\n<\/ol>\n<h3><\/h3>\n<h3><span class=\"ez-toc-section\" id=\"Using_apt_apt-get_command\"><\/span>Using apt (apt-get) command<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>The apt command usually installs the Open-JDK java.<br \/>\nCommand:<br \/>\n<em>sudo apt-get install default-jdk<\/em><\/p>\n<p>Sometimes it is necessary to use Oracle&#8217;s versions due to compatibilities issues.<br \/>\nI usually install them manually, but it may be used apt-get when you add the source into \/etc\/apt\/sources.list.<br \/>\nIn these cases, the documentation will lead you.<br \/>\nI rarely use this.<\/p>\n<p>&nbsp;<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Manual_installation\"><\/span>Manual installation<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>A very good solution and very flexible. Easy and fast that enables to work with many different types.<br \/>\nDownload the tar file and extract its content.<br \/>\nMove its content to another directory, other than the &#8220;Download&#8221; dir.<br \/>\nCreate the command to use that version. For instance:<\/p>\n<p>nano myCmd<br \/>\n<em>&#8220;$JAVA_PATH\/bin\/java&#8221; -jar myApp.jar<\/em><\/p>\n<p>chmod 775 myCmd<\/p>\n<p>To run:<br \/>\n.\/myCmd<\/p>\n<p>&nbsp;<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Framework_With_Installer\"><\/span>Framework With Installer<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>The installer will do everything.<br \/>\nJust follow the instructions.<\/p>\n<p>&nbsp;<\/p>\n<h2><span class=\"ez-toc-section\" id=\"SET_AND_RESET_JAVA_ENV\"><\/span>SET AND RESET JAVA ENV<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Here comes when things get more interesting and where the issues happen.<\/p>\n<p>The tools to discover your java env:<\/p>\n<p>Which installation is working to run &#8220;java&#8221; command:<br \/>\n<em>java -version<\/em><\/p>\n<p>When you have no idea where the installations may be:<br \/>\n<em>whereis java<\/em><\/p>\n<p>Which options do the environment have?<br \/>\n<em>sudo update-alternatives &#8211;config java<\/em><\/p>\n<p>&nbsp;<\/p>\n<h3><span class=\"ez-toc-section\" id=\"SWITCHING_THE_ENVIRONMENTS_JAVA_VERSION\"><\/span>#SWITCHING THE ENVIRONMENT&#8217;S JAVA VERSION<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>When the comand<\/p>\n<p><em>sudo update-alternatives &#8211;config java<\/em><\/p>\n<p>works, it is easy. Just get the option you desire.<\/p>\n<p>&nbsp;<\/p>\n<h3><span class=\"ez-toc-section\" id=\"MANUAL_SWITCH\"><\/span>#MANUAL SWITCH<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Sometimes, the environment has some issue and things don&#8217;t go as you expect requiring some radical procedures, they are:<\/p>\n<p>Install the default java, even though you do not wish it.<\/p>\n<p><em>sudo apt-get install default-jdk<\/em><\/p>\n<p>&nbsp;<\/p>\n<p>Test using the commands:<br \/>\njava -version<br \/>\n<em>sudo update-alternatives &#8211;config java<\/em><\/p>\n<p>The 1st cmd must return the same version as default and the second shall show at least one option.<\/p>\n<h3><\/h3>\n<h3><span class=\"ez-toc-section\" id=\"WHEN_THINGS_DONT_HAPPEN_AND_HOW_TO_FIX\"><\/span>WHEN THINGS DON&#8217;T HAPPEN AND HOW TO FIX<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>&nbsp;<\/p>\n<p>Uninstall the default java previously installed:<\/p>\n<p><em>sudo apt-get purge default-jdk<\/em><\/p>\n<p><em>sudo apt update<\/em><\/p>\n<p>&nbsp;<\/p>\n<p>Force removing the java appointment:<\/p>\n<p><em>sudo rm \/usr\/bin\/java<\/em><\/p>\n<p>&nbsp;<\/p>\n<p>Reinstall java default:<\/p>\n<p><em>sudo apt-get install default-jdk<\/em><\/p>\n<p>&nbsp;<\/p>\n<p>Retest.<br \/>\nIf it fails, try one more.<br \/>\nIf it still fails, reboot the system and repeat the installation and uninstallation procedures and reboot again.<\/p>\n<p>If successful, you shall get this:<\/p>\n<p><em>sudo ls -al \/usr\/bin\/java<\/em><br \/>\n<em>lrwxrwxrwx 1 root root 22 Jan 5 19:45 \/usr\/bin\/java -&gt; \/etc\/alternatives\/java<\/em><\/p>\n<p><em>sudo ls -al \/etc\/alternatives\/java<\/em><br \/>\n<em>lrwxrwxrwx 1 root root 43 Jan 5 19:45 \/etc\/alternatives\/java -&gt; \/usr\/lib\/jvm\/java-11-openjdk-amd64\/bin\/java<\/em><\/p>\n<p>&nbsp;<\/p>\n<p>Well, and if still fails, there is still one workaround.<br \/>\nUse the absolut path to call java. Ex.:<\/p>\n<p>JAVA_HOME\/bin\/java -version<\/p>\n<h4><span class=\"ez-toc-section\" id=\"NOTE\"><\/span>NOTE:<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<p><span style=\"color: #993300;\"><strong>WRONG: this way doesn&#8217;t work:<\/strong><\/span><\/p>\n<p><span style=\"color: #808080;\">ln -s \/home\/portables_d\/jdk1.6.0_30_64\/bin\/java java630<\/span><br \/>\n<span style=\"color: #808080;\">java630 -version<\/span><\/p>\n<p>Returns:<\/p>\n<p><span style=\"color: #808080;\">java630 -version<\/span><br \/>\n<span style=\"color: #808080;\">java630: error while loading shared libraries: libjli.so: cannot open shared object file: No such file or directory<\/span><br \/>\n<span style=\"color: #808080;\">alsdias@vmvd20 $ \/home\/portables_d\/jdk1.6.0_30_64\/bin\/java -java<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #0000ff;\"><strong>RIGHT: this way works:<\/strong><\/span><\/p>\n<p>\/home\/portables_d\/jdk1.6.0_30_64\/bin\/java -version<\/p>\n<p>Returns:<\/p>\n<pre class=\"\">Java(TM) SE Runtime Environment (build 1.6.0_30-b12)\r\nJava HotSpot(TM) 64-Bit Server VM (build 20.5-b03, mixed mode)\r\n<\/pre>\n<p>&nbsp;<\/p>\n<!--CusAds0-->\n<div style=\"font-size: 0px; height: 0px; line-height: 0px; margin: 0; padding: 0; clear: both;\"><\/div>","protected":false},"excerpt":{"rendered":"<p>Scenario Suppose that you try to start an Eclipse installation, and it fails returning exit code 8, 13, etc. , something like &#8220;java terminated exit code 8&#8220;. This is usually caused due to the version of Java used by the environment that it is incompatible with the version of the Eclipse installation. Another situation comes &#8230; <a href=\"https:\/\/ultering.com\/it4us\/?p=5588\" class=\"more-link\">Read More<span class=\"screen-reader-text\"> &#8220;Java: Handling Java Installation on Debian\/Ubuntu &#8211; Eclipse fails with exit code&#8221;<\/span> &raquo;<\/a><\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"footnotes":""},"categories":[12],"tags":[],"class_list":["post-5588","post","type-post","status-publish","format-standard","hentry","category-java"],"_links":{"self":[{"href":"https:\/\/ultering.com\/it4us\/index.php?rest_route=\/wp\/v2\/posts\/5588","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ultering.com\/it4us\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ultering.com\/it4us\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ultering.com\/it4us\/index.php?rest_route=\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/ultering.com\/it4us\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5588"}],"version-history":[{"count":6,"href":"https:\/\/ultering.com\/it4us\/index.php?rest_route=\/wp\/v2\/posts\/5588\/revisions"}],"predecessor-version":[{"id":5615,"href":"https:\/\/ultering.com\/it4us\/index.php?rest_route=\/wp\/v2\/posts\/5588\/revisions\/5615"}],"wp:attachment":[{"href":"https:\/\/ultering.com\/it4us\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5588"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ultering.com\/it4us\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5588"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ultering.com\/it4us\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5588"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}