try using this command in the terminal:
sudo apt install default-jre
then you can try using:
java -version
to check version
Answer from neoMidori on askubuntu.comTrying to install Java now.
Installing Java 7 on Ubuntu - Stack Overflow
java - How to install the JDK on Ubuntu Linux - Stack Overflow
Noob question. How do I update to Java 22 via terminal?
Videos
try using this command in the terminal:
sudo apt install default-jre
then you can try using:
java -version
to check version
Do not download binaries straight from the Internet. That is not how to install software on Linux. It is how Windows users do it, but it is wrong on Linux.
Install it from the package manager. Google for instructions for your version, since you did not bother to tell us what you are running. Without detailed specific info we can't help you.
So this morning I asked for help with .deb files. That is now working. I'm trying to open a .jar file. Said file won't open without Java. Yes I have Java running but because of the stupid way .jars are it won't let me open it without going through Java and I just wanna play modded Minecraft. Any help would be greatly appreciated.
Before I start, please note that the JDK also contains the JRE within it.
Method 1:
To install the openJDK JDK and JRE 8 use (replace 8 with the version you want, such as 7 or 6):
sudo apt-get install openjdk-8-jdk
Method 2:
If you instead want to install the official Oracle JDK and JRE and definitely want to install through apt-get then do (you can replace the 8 with other versions such as 9, or 7):
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer
Method 3:
Or if you want to install the official Oracle Java version manually:
Go here and click the download button:

Select the Accept License Agreement radio button (once you have read the license agreement).
Select the file you want to download, if you are running on a 32-bit machine click
jdk-[javaversion]-linux-i586.tar.gz([javaversion]replaced with the Java version, such as8u60), if 64-bit thenjdk-[javaversion]-linux-x64.tar.gz.Launch Terminal (CTRL + ALT + T), then
cdto the directory where you downloaded the file to (probably~/Downloads), and runtar -xvf /path/to/file.tar.gzto unpack that archive into the directory the file is in, you may then move that unpacked archive into a desired location, such as the/optdirectory (storing executable files in your home directory is a security risk).Once you have done the above you may delete the original
.tar.gzfile, and then open up your~/.bashrcfile in a desired file editor such asgeditorvim, I will be usingvimin this example (install it withsudo apt-get install vimif it is not already installed). So runvim ~/.bashrcand then insert two new lines at the bottom of the file which read (that is with/path/to/unpacked/archivereplaced with the path to the archive you just unpacked):JAVA_HOME=/path/to/unpacked/archive export PATH=$PATH:$JAVA_HOME/binEither restart Terminal or run
source ~/.bashrcto start using the new.bashrcfile.Note: With this method you will have to carry on doing this every time there is a new Java version released which it will not notify you about.
Open terminal and type
sudo apt-get install openjdk-7-jre
This package contains the Java Runtime Environment
This answer used to describe how to install Oracle Java 7. This no longer works since Oracle end-of-lifed Java 7 and put the binary downloads for versions with security patches behind a paywall. Also, OpenJDK has grown up and is a more viable alternative nowadays.
In Ubuntu 16.04 and higher, Java 7 is no longer available. Usually you're best off installing Java 8 (or 9) instead.
sudo apt-get install openjdk-8-jre
or, f you also want the compiler, get the jdk:
sudo apt-get install openjdk-8-jdk
In Trusty, the easiest way to install Java 7 currently is to install OpenJDK package:
sudo apt-get install openjdk-7-jre
or, for the jdk:
sudo apt-get install openjdk-7-jdk
If you are specifically looking for Java 7 on a version of Ubuntu that no longer supports it, see https://askubuntu.com/questions/761127/how-do-i-install-openjdk-7-on-ubuntu-16-04-or-higher .
sudo apt-get update
sudo apt-get install openjdk-7-jdk
and if you already have other JDK versions installed
sudo update-alternatives --config java
then select the Java 7 version.
Referring to Ask Ubuntu question How to set JAVA_HOME for OpenJDK?,
How to install Open JDK (Java developement kit) in Ubuntu (Linux)?
Open Terminal from Application Dash or press Ctrl+Alt+T
Update repository:
sudo add-apt-repository ppa:openjdk-r/ppa # only Ubuntu 17.4 and earlier sudo apt updateOptional: To search available distributions of
openjdk, use the following command:apt search openjdkInstall the appropriate version with the following command:
sudo apt install openjdk-8-jdk sudo apt install openjdk-8-source #this is optional, the jdk source codeFor
JAVA_HOME(Environment Variable) type command as shown below, in "Terminal" using your installation path...export JAVA_HOME=/usr/lib/jvm/java-8-openjdk(Note:
/usr/lib/jvm/java-8-openjdkis symbolically used here just for demostration. You should use your path as per your installation.)For
PATH(Environment Variable) type command as shown below, inTerminal:export PATH=$PATH:$JAVA_HOME/binTo check your installation:
java -version
The following used to work before the Oracle Java license changes in early 2019.
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java7-installer
The PPA is discontinued, until the author finds a workaround for the license issues.
SOLVED. Thanks!
Version Ubuntu 24.04.03 LTS, currently on Java 21, need 22 for my Minecraft server but sudo apt install openjdk-22-jdk gives error, unable to locate package. Just apt update just gives you version 21 as that's what seems to be on Ubuntu rn.
I suspect I need to download whatever .tar.gz for java, send it over via FTP, SSH back in and run it somehow but I haven't actually done that before and am not that technically savvy so hoping someone has a clearer tutorial then Google being like just reinstall Ubuntu so there's a GUI.