How to install Java on Ubuntu Server? - java

I need to install Oracle JDK 11 on Ubuntu Server 18.04. I have seen many tutorials but all of those point that I need to download this repository:
sudo add-apt-repository ppa:linuxuprising/java
But it is not working. This is what I get:
Also, I need to install Open JDK 14 in the same Ubuntu machine, but I'm unable to find working instructions.
Does somebody have any hints on these issues?

Actually it should be possible to just type "sudo apt-get install openjdk-11-jdk" or "sudo apt-get install openjdk-14-jdk"
This should Help you with all the OpenJDK stuff
https://wiki.ubuntuusers.de/Java/Installation/OpenJDK/

Related

Can't install OpenJDK 8 due to not having an installation candidate

I am on Debian 9 and am trying to install OpenJDK 8. When I enter the command sudo apt install openjdk-8-jre-headless, however, I get an error saying E: Package 'openjdk-8-jre-headless' has no installation candidate. I have installed build-essential and git, but it still does not work. Does anyone know how to fix this?
git has nothing to do with it. Your OS can't find a package containing openJDK 8. Try apt-cache openjdk-8 to see if there are any known packages containing what you need.
If the cachecommand finds a package, use your favorite editor to add it to /etc/apt/sources.list and try installing again.
If cache cannot find what you want in a current package, search through old packages at http://snapshot.debian.org/.
You can download by the following way :
sudo add-apt-repository ppa:openjdk-r/ppa
sudo apt-get update
sudo apt-get install openjdk-8-jre

Ubuntu: Oracle JDK 8 is NOT installed

I've installed oracle JDK-8 on ubuntu 14.04 manually. but whenever I want to install a package that needs jdk8, apt-get tries to install jdk 8 again. my country is restricted so oracle server won't allow me to download jdk8.
$java -version
java version "1.8.0_45"
Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)
and the results of apt-get are:
download failed
Oracle JDK 8 is NOT installed.
dpkg: error processing package oracle-java8-installer (--configure):
subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
oracle-java8-installer
E: Sub-process /usr/bin/dpkg returned an error code (1)
with this error, apt-get won't finish the installation.
oracle-java8-installer is not able to download file. So downlaod it manually from Oracle site and put into folder /var/cache/oracle-jdk8-installer/. And try to install oracle-java8-installer again. This solved the problem for me.
Step by step:
Check what file oracle-java8-installer is not able to download. You can see it in installation log. Let's suppose it's jdk-8u111-linux-x64.tar.gz
Google it jdk-8u111-linux-x64.tar.gz and you'll find exact page on Oracle site where to download it from. For our example it's http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
Download jdk-8u111-linux-x64.tar.gz file and put in into folder /var/cache/oracle-jdk8-installer/.
And try to install oracle-jdk8-installer again: sudo apt-get install oracle-java8-installer Installation should finish successfully.
Try this,
First update the apt-get repos
$ sudo apt-get update
Add the java 8 repo to apt-get
$ sudo add-apt-repository ppa:webupd8team/java
Again update the apt-get repo
$ sudo apt-get update
Finally install java 8
$ sudo apt-get install oracle-java8-installer
References:
Ubuntu 16.04
Ubuntu 18.04
the first step:
sudo apt-get remove oracle-java8-installer
to clean up the failure installation of java8 perviously.
the second step:
sudo apt-get install oracle-java8-installer
to reinstall Java8
I suspect you've installed Oracle JDK8 using the archive, extracting to your own folder. It's probably the case that Ubuntu doesn't know that you've installed Java as the system Java and so is raising the error.
To be honest, I'm not sure how you go about installing it for system wide use but this page may provide some pointers. Installing Open JDK might be the better option, but an option is also given here, and this answer might also help.
One of the possible reasons and solution could be, that the version of the java package is updated with the possible vulnerability patch fix, and that needs to be updated in the PPA. I faced this when installing on ubuntu 16.04.
If the specific download error is that java download link is 404, than mostly
this solution will work.
Please remember to update the versions accordingly.
This worked for me:
First, go to below path:
cd /var/lib/dpkg/info
Run all 4 sed commands:
sudo sed -i 's|JAVA_VERSION=8u161|JAVA_VERSION=8u172|' oracle-java8-installer.*
sudo sed -i 's|PARTNER_URL=http://download.oracle.com/otn-pub/java/jdk/8u161-b12/2f38c3b165be4555a1fa6e98c45e0808/|PARTNER_URL=http://download.oracle.com/otn-pub/java/jdk/8u172-b11/a58eab1ec242421181065cdc37240b08/|' oracle-java8-installer.*
sudo sed -i 's|SHA256SUM_TGZ="6dbc56a0e3310b69e91bb64db63a485bd7b6a8083f08e48047276380a0e2021e"|SHA256SUM_TGZ="28a00b9400b6913563553e09e8024c286b506d8523334c93ddec6c9ec7e9d346"|' oracle-java8-installer.*
sudo sed -i 's|J_DIR=jdk1.8.0_161|J_DIR=jdk1.8.0_172|' oracle-java8-installer.*
Second:
sudo apt-get install oracle-java8-installer
If OpenJDK also OK for you, try to use sdkman for installing all java staff) It's a very cool tool.

Install webstorm but no jdk found on ubuntu 14.04LTS

I am trying to install webstorm, but when I try to run the *.sh file it gives me error of not having java environment available.
So I tried to look into the official documentation
But the steps to install the jdk didn't worked. I tried to locate java folder, but couldn't locate this directory /usr/bin/java
Please guide me how I can install webstorm now?
Java generally installs in /usr/lib/jvm/java-[major version]-openjdk-[arch]. Install a package such as openjdk-7-jdk and check in that location.
If you already have java installed, running which java will tell you the path of the java executable.
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java7-installer
I haven't tried with java-8. Then:
sudo update-alternatives --java
And set auto-mode or java-7 (You might try with java-8)
First check the about java version
java -version
if its not returning you need to check your installed jdk
go to
cd /usr/lib/jvm
if you are finding something which start with java_XXXX
it means this is the only your jdk, and you can set JAVA_HOME as well path till bin folder by using export
I had a similar problem, during installation of eclipse (openjdk-7-jdk was required). I used
> sudo apt-get update
> sudo apt-get install ...
and it worked.
You should just install a JRE (to allow Java execution programs) and not a JDK (to develop Java programs).
No need a JDK to allow Webstorm to lauch.
On ubuntu : apt-get install default-jre
Have a nice day :)
David

How can I install Eclipse and Java SDK on Ubuntu?

I have just downloaded Ubuntu. It runs much faster than my Windows XP. But, I don't know how I can set up Eclipse v4.2 (Juno), or the Java SDK. I am currently developing in the Lightweight Java Game Library, so I might need some help with that too.
Execute this in your terminal:
sudo apt-get install eclipse
sudo apt-get install openjdk-6-jdk openjdk-6-source openjdk-6-demo openjdk-6-doc openjdk-6-jre-headless openjdk-6-jre-lib
The first one installs Eclipse (you will be asked to enter your password), and the second one installs all the Java stuff you may need!
Don't install Eclipse from the Linux repositories. These repositories may not be up-to-date with the last versions released by Eclipse. A better approach is to follow the instructions in this answer from Ask Ubuntu. For Java programming, make sure you have a JDK and a JRE installed
apt-get install openjdk-7-jdk openjdk-7-jre
You can download whatever Eclipse Java IDE version suits you best from the Eclipse website (link to the Eclipse v4.4 (Luna) release).
You might want to consider installing Sun Java 6 for your Java programming needs; correct me if I'm wrong, but I feel that OpenJDK may still be lacking in some libraries and compatibilities.
If you want to install Java 6 on your machine, you can follow this guide on how to do so: https://codingforme.wordpress.com/2012/05/14/installing-oracle-java-jdk-6-or-7-on-ubuntu-12-04/
Java installation on Ubuntu:
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer
Eclipse IDE installation on Ubuntu:
Since it requires a detailed list of steps, I would suggest you to visit the blog post Install Eclipse IDE Mars in Linux Ubuntu to check out steps to install Eclipse on Linux Ubuntu.
You don't really install Eclipse - you just download the folder and run the program - just like in windows. Just make sure you download a Linux version.
To install JDK, type:
sudo apt-get install openjdk-6-jdk
You will be asked to type in your password before the installation will begin. You could also install JDK through the software manager.
Just remove all Eclipse packages typing:
sudo apt-get autoremove eclipse
And with tab find all installed Eclipse packages.
Do the same with Java.
I just reinstalled Eclipse with the command
sudo apt-get install eclipse
which also contains Java.

Launch4j maven plugin will not work on 64-bit linux machine

I am trying to use the maven Launch4j plugin version 1.5.0.1
When I build the pom on my windows box, there is no issue (my windows box has both 32-bit and 64-bit versions of Java installed). But when I build the pom on my linux box, I get this issue:
Stack trace:
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.bluestemsoftware.open.maven.plugin:launch4j-plugin:1.5.01.1..... Failed to build executable; please verify your configuration
Cause by: net.sf.launch4j.BuilderException: net.sf.launch4j.ExecException: java.io.IOException: Cannot run program "/home/hudson/.m2/repository/org/bluestemsoftware/open/maven/plugin/launch4j-plugin/1.5.0.1/launch4j-plugin-1.5.0.1-workdir-linux/bin/windres": java.IOException: error=2, No such file or directory
I did quite a bit of digging around and I found this:
http://alakai.org:8088/browse/LAUNCHPLUGIN-15
But, the task is still open, so I can only assume that there is no fix in place for this issue on a 64-bit Linux OS that uses 64-bit java. Unfortunately, my linux box cannot access an external network, so installing 32-bit java is not much of an option. Does anyone know of any other possible work-arounds?
Just install ia32-libs for your distrib. On my ubuntu machine: sudo apt-get install ia32-libs
On recent x64 Ubuntu distributions (starting 14.04 LTS, tested on 16.04 LTS), do this:
$ sudo dpkg --add-architecture i386
$ sudo apt-get update
$ sudo apt-get install lib32z1 lib32ncurses5 libbz2-1.0:i386
For Fedora, install the 32 bit version of openjdk-devel. java-1.6.0-openjdk-devel.i686 or java-1.7.0-openjdk-devel.i686.
yum install java-1.6.0-openjdk-devel.i686
... or ...
yum install java-1.7.0-openjdk-devel.i686
Use yumdownloader on a different machine if you can not reach the network.

Categories