Ubuntu 18.04 Java Command Not Found Despite Being Installed - java

I initially had default-jdk and default-jre installed on Ubuntu 18.04.
Attempted to host a Minecraft Server for a friend, but was given the error found here
I followed the commentor's advice to reinstall java version 8 rather than version 11 installed above, by following this advice here that being
sudo rm -r /usr/lib/jvm/java-11-oracle
but as a mistake I had removed all files in that folder, leaving just the two directories
java-11-openjdk-amd64
java-8-openjdk-amd64
since then I have attempted to reinstall java using sudo apt-get install default-jdk ; sudo apt-get install default-jre and they install just fine, but running java -version, either as root or as user, returns:
Command 'java' not found, but can be installed with:
sudo apt install default-jre
sudo apt install openjdk-11-jre-headless
sudo apt install openjdk-8-jre-headless
I have scoured askubuntu, digitalocean, and stackoverflow for some answers but I can't find anything that fixes this problem. I also asked my roommate, who is an experienced Computer Science major and who has used ubuntu extensively in the past, and he couldn't find a solution. Has anyone encountered this issue before?
I appreciate any and all responses 😊

Solution has been found. Running:
sudo apt purge -y openjdk-11-jre-headless
sudo apt purge -y openjdk-8-jre-headless
sudo apt purge -y default-jdk
and reinstalling has resolved the issue

Check your path. You should have remove the old jdk using apt-get. I think your system still assumes the old jdk-11 is still present. You could try to re-install it or use update-alternatives to switch to the other version.

Related

Unable to install java in Ubuntu due to broken packages

I am trying to install java in my ubuntu software.Every time i am trying to install JRE or JDK it says:
~The following packages have unmet dependencies:
default-jre : Depends: default-jre-headless (= 1:1.6-43ubuntu2) but it is not going to be installed
Depends: openjdk-6-jre (>= 6b23~pre11-1ubuntu1~) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
and basically anything i try to do is stopped from some broken packages.I tried some cleaning techniques of apt and stuff but nothing helped also.Thank you in advance.
You can try apt-get install -f, which should try to resolve the conflict.
If it does, and there are no more conflicts, then you can try and install apt-get install default-jre
This issue is a conflict between the OpenJDK and Oracle's own DEB distributions for Ubuntu, especially if you've used the webupd8 PPA in the past to install it. I solved it by forcing the override:
sudo apt -o Dpkg::Options::="--force-overwrite" --fix-broken install
You can also force it directly with dpkg by running
sudo dpkg --configure --force-overwrite -a

installing DR java on ubuntu 18.04

I will be attending computer science classes and we are asked to be using DrJava, but am using linux os and I don't know how to install DrJava on ubuntu. Please help me.
I tried to download a jar file for DrJava and run below command
java-jar drjava-stable-20190813-220051
But this is the response I get;
Command 'java' not found, but can be installed with:
sudo apt install default-jre
sudo apt install openjdk-11-jre-headless
sudo apt install openjdk-8-jre-headless
Run
sudo apt install openjdk-8-jdk
And try again.

Ubuntu 16.04: Oracle JDK 9 is NOT installed

Every time I try to install something from terminal this message pops up to me. Meanwhile I have my Java installed right:
download failed
Oracle JDK 9 is NOT installed.
dpkg: error processing package oracle-java9-installer (--configure):
subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
oracle-java9-installer
E: Sub-process /usr/bin/dpkg returned an error code (1)
Please can someone help me solve this; it's really annoying.
sudo apt-get purge oracle-java9-installer
solved my issue.
Later I also changed Ubuntu Software center server to "Main Server".
Actually I hit the issue after resolving the wine installation on my Ubuntu 16.04 LTS box. The wine issue I resolved using the below link.
https://askubuntu.com/questions/935050/unknown-error-class-keyerror-the-cache-has-no-package-named-wine1-6-i38
So that landed me to this post. But I was not able to install the java from apt packages. It threw me errors. Then I realized it was the issue of having multiple Java instances on my system. I already had Oracle Java 9 installed. I just needed to change the current verions using the command
sudo update-alternatives --config java
So if any body hits the error, you can try setting this.
I was getting the same error so using this command first i removed Java 9
sudo apt remove oracle-java9-installer
Then I made Java 8 as default
sudo apt-get install oracle-java8-set-default
After this if you try to install other software it will work or you can also upgrade Java 8 to Java 9.
First, add Oracle's PPA, then update your package repository.
$sudo add-apt-repository ppa:webupd8team/java
$sudo apt-get update
To install JDK 9, use the following command:
$sudo apt-get install oracle-java9-installer
I'm not sure what steps you have tried already to install it but the link below is a fairly well explained description of how to install the JDK on Ubuntu. I've always installed the JDK through the webupd8team's ppa and its worked for me so far :)
A note about the link, it suggests setting the home variable, this may be necessary for you but I've never had to it manually and it's worked so give it a quick check before setting the home variable yourself.
https://www.digitalocean.com/community/tutorials/how-to-install-java-with-apt-get-on-ubuntu-16-04
Solved the problem removing all java versions and purging them and re-installing them again probably, thanks everyone who tried to help.
Completely removal criteria:
To remove Oracle JDK completely, run the commands below:
sudo apt-get remove oracle-java9-installer
sudo apt-get remove --auto-remove oracle-java9-installer
sudo apt-get purge oracle-java9-installer
sudo apt-get purge --auto-remove oracle-java9-installer
Resource Link:
https://www.howtoinstall.co/en/ubuntu/trusty/tomcat7?action=remove
After that, install jdk9 using the following command:
Install JDK9 in Ubuntu:
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java9-installer
Make it as default:
sudo apt-get install oracle-java9-set-default
Resource Link:
http://zakirrizvi.blogspot.com/2017/10/install-jdk9-in-ubuntu.html

Unable to install Android Studio in Ubuntu [duplicate]

This question already has answers here:
Error: Unable to run mksdcard SDK tool
(10 answers)
Closed 6 years ago.
I'm using Ubuntu Gnome 14.04, and I have Java 8 installed (both the JDK and the JRE).
When I was installing Android Studio everything worked, but a message appeared saying:
Unable to run mksdcard SDK tool
How can I install Android Studio correctly, or how do I fix this ?
Presuming that you are running the 64bit Ubuntu, the fix suggested for "Issue 82711" should solve your problem.
sudo apt-get install lib32z1 lib32ncurses5 lib32bz2-1.0 lib32stdc++6
Update:
For Ubuntu 15.10 & 16.04
sudo apt-get install lib32z1 lib32ncurses5 lib32stdc++6
#warsong is right. Installing only lib32stdc++6 solved the problem.
For next uses I rewrite #warsongs comment in answer area.
sudo apt-get install lib32stdc++6
Update :
For Ubuntu 15.04,15.10,16.04 LTS & Debian 8
For Fedora (tested for Fedora 23/24) run
dnf install compat-libstdc++-296 compat-libstdc++-33 glibc libgcc nss-softokn-freebl libstdc++ ncurses-libs zlib-devel.i686 ncurses-devel.i686 ant
I understand the question is regarding UBUNTU, but I had similar problem in Debian Jessie 64bit and warsongs suggestion worked for it also.
When I ran studio.sh android studio would start, but when I tried to configure the android SDK I got the error
Unable to run mksdcard SDK tool
WHen I tried
sudo apt-get install lib32z1 lib32ncurses5 lib32bz2-1.0 lib32stdc++6
Got error
E: Package 'lib32bz2-1.0' has no installation candidate
So took warsongs suggestion and only tried to install lib32stdc++6.
sudo apt-get install lib32stdc++6
After this was able to add the Android SDK into Android Studio.
Checkout this page
If you are running a 64-bit distribution on your development machine, you need to install additional packages first. For Ubuntu 13.10 (Saucy Salamander) and above, install the libncurses5:i386, libstdc++6:i386, and zlib1g:i386 packages using apt-get:
sudo dpkg --add-architecture i386
sudo apt-get update
sudo apt-get install libncurses5:i386 libstdc++6:i386 zlib1g:i386
The Problem is caused by mksdcard not being installed correctly.
if you are running 64 bit, do this to fix the mksdcard problem.
sudo dpkg --add-architecture amd64
sudo apt-get update
sudo apt-get install libncurses5:amd64 libstdc++6:amd64 zlib1g:amd64
and 32 bit:
sudo dpkg --add-architecture i386
sudo apt-get update
sudo apt-get install libncurses5:i386 libstdc++6:i386 zlib1g:i386
In SDK 6.0, the error message is different but means the same thing.
Unable to run mksdcard
None of these options worked for me on Ubuntu 12.10 (yeah, I need to upgrade). However, I found an easy solution. Download the source from here: https://github.com/miracle2k/android-platform_sdk/blob/master/emulator/mksdcard/mksdcard.c. Then simply compile with "gcc mksdcard.c -o mksdcard". Backup mksdcard in the SDK tools subfolder and replace with the newly compiled one. Android Studio will now be happy with your SDK.
For Linux Mint run
sudo apt-get install lib32z1 lib32ncurses5 libbz2-1.0 lib32stdc++6
If you run sudo apt-get install lib32z1 lib32ncurses5 libbz2-1.0 lib32stdc++6
and got a message like: "The following packages have unmet dependencies: lib32stdc++6 : Depends: lib32gcc1 (>= 1:4.1.1)".
You can do something like this tut: https://askubuntu.com/questions/671791/lib32stdc6-package-depends-on-gcc-base-but-my-installed-version-is-newer
This issue arises when your 64 bit os tries to install the Android SDK which in turns tries to install some 32 bit binaries and thus is the issue of compatibility.
Open an additional terminal and type
sudo apt-get install lib32z1 lib32ncurses5 lib32bz2-1.0 lib32stdc++6
would help to install all the required binaries. After this, start the afresh the Android SDK installation process.

Javac 1.8.0_25 has known bug - how to use different version?

My travis build fails - and I think it is because of a known JDK-bug.
How can I force travis to use the 1.8.0_40 java compiler (instead of 1.8.0_25), so that I do not run into this compiler bug?
Upgrading could be an option, with following pre-install steps in your .travis.yml:
before_install:
- sudo apt-get sudo apt-get update -qq
- sudo apt-get install --only-upgrade -y oracle-java8-installer
but Travis CI environments are installing Oracle JDK 8 from ppa:webupd8team/java and as you can see there, WebUpd8 Team has not released yet a newer package than 1.8.0_25. So this method won't bring you 1.8.0_40 today.
Downgrading is also a possible approach:
before_install:
- wget https://launchpad.net/~webupd8team/+archive/ubuntu/java/+files/oracle-java8-installer_8u11%2B8u6arm-1~webupd8~3_all.deb -O oracle-java8-installer.deb
- sudo dpkg -i oracle-java8-installer.deb
And it actually solves your problem: https://github.com/tbsalling/aismessages/pull/6 :)

Categories

Resources