Making Oracle JDK automatically updateable in Ubuntu or GNU/Linux OS - java

I'm facing a problem about Oracle JDK in my Ubuntu 16.04.2 LTS OS.
I downloaded Oracle JDK Linux_x64 -version 8u131 tar.gz file from official website. I extracted the file in /home/ashik/Applications/ directory and I exported path in .bashrc file like,
export JAVA_HOME=/home/ashik/Applications/jdk-8u131-linux-x64/
export PATH=$JAVA_HOME/bin:$PATH
It's working fine but I want to make this jdk version auto upgradeable. If I use openjdk from official repository it provides update packages time to time. I want to do something like that for Oracle JDK. If Oracle release any updated version then it should be upgraded in my system automatically. In Microsoft Windows system this JDK informs when any update appear. Developers can upgrade the JDK if they want then. I want to do something like that.
I know there have some suggestions to use openjdk or using PPA but I don't want to do so. I want to get update file from Oracle directly. I know there has a way to download upgraded version from Oracle's website and replace it in that path but i don't want to follow any of these ways. I want to do something which will take care the whole updating system by itself automatically.
If there is any way to do so?
My System Information:
OS: Ubuntu 16.04.2 LTS , DE: Gnome 3

You can write a shell scrip to do this for you. If you want to automate accepting oracle license, you can do something like here:
https://github.com/appscode/Dockerfiles/blob/master/oracle-jdk/Dockerfile#L5
This is a common pattern used to build JDK docker images.
To download JDK archive from Oracle's website, you can use something like below:
curl -b oraclelicense=accept-securebackup-cookie -L 'http://download.oracle.com/otn-pub/java/jdk/8u112-b15/server-jre-8u112-linux-x64.tar.gz'

Related

who is the distributor of openjdk docker image

my understanding is you need to have a distributor to use openjdk someone like (oracle openjdk, adoptopenjdk) but on docker repo for openjdk how do I find out who is the distributor if I just use their reference documentation
{the code below in copied from openjdk official docker repo}
FROM openjdk:11
COPY . /usr/src/myapp
WORKDIR /usr/src/myapp
RUN javac Main.java
CMD ["java", "Main"]
moving from java 8 to java 11
It's all written there on the docker page: https://hub.docker.com/_/openjdk/
openjdk:<version>
This is the defacto image. [...] These are the suite
code names for releases of Debian and indicate which release the image
is based on. [...]
openjdk:<version> (from 12 onwards), [...]
Starting with openjdk:12
the default image as well as the -oracle and -oraclelinux7 variants
are based on the official Oracle Linux 7 image which is provided under
the GPLv2 as per the Oracle Linux End User Agreement (EULA). [...]
TL;DR: the images are maintained by the Docker community, versions < 12 ship the OpenJDK build from Debian or Alpine Linux, later versions ship the Oracle builds.
By the way, until Version including 8, the Oracle JDK was more freely available. Anyway, Linux distributions built their own binaries. The binary distributions by AdoptOpenJDK, Amazon Corretto, etc. are only there, because Oracle doesn't provide binary builds freely anymore. But you can download OpenJDK and build it yourself, if you like.
Edit: You could also ssh into the image and run java -version
Edit2: Java 7 and support
I want to address your comment on my answer. You specifically asked for Java version 7. This version is quite old (first release in 2011!) and you will not find any long term support for without paying for commercial support. Period.
This version also predates the license changes to Oracle binaries, so the whole AdoptOpenJDK argument doesn't matter.
On the OpenJDK Docker Hub page, you can see different images shipping Java 7 builds, some with Alpine Linux and some with Debian Jessie. Those are - presumably, I've only verified that for Debian - builds of the open source OpenJDK project by that distribution. So the GPL with classpath exception should be the license that applies (read: you can use it commercially).
Note that even the LTS-support for Debian Jessie ends next month: https://wiki.debian.org/LTS
That shouldn't be necessarily a problem, depending on where you want to run that image (i.e., facing the public internet vs. private intranet).
If you have to stick with such an old version of Java, you have few options (maybe taking a modern linux image and build OpenJDK yourself [that will be painful, I imagine]).
Edit3: Recent version 7 support and v8+ from AdoptOpenJdk
OK, so you clarified in your comment, that you are not actually looking for version 7 builds.
I did, however, find an up-to-date and supported build of Java 7, by Azul: https://hub.docker.com/r/azul/zulu-openjdk
But you said you're running version 8, looking to go to 11. Then I would highly recommend AdoptOpenJDK, which is currently the most popular build. They offer Docker images as well (Note: they offer different JVMs: Hotspot is the default and highly recommended, OpenJ9 is based on a development by IBM)

What are the parameters set by the JRE installer in my linux machine apart from copying JRE files?

I am writing a Java Swing application. I downloaded JRE for Linux platfrom from Oracle website and just bundled this JRE my application.
I have given a launcher script, in which I am referring the bundled JRE bin/java executable. So it works fine.
My question is, what is the difference between installing the JRE by downloading from the Oracle website and this procedure?
What are the extra parameters set by the JRE installer in my Linux machine apart from copying JRE files?
What are the environment variables set and what are the shared libraries copied? Any idea?
It depends a lot on how you install.
First, I assume you are talking about Java 8, since later versions of Java don't come with a separate JRE.
For Oracle Java 8 installations for Linux, there is a choice of rpm or other package installers or the basic Linux manual installation. The latter is described here. As you can see from the documentation, it's just a simple tar.gz which you unzip/untar into a directory of your choice, and that's it. The same as your bundled JRE.
if you want develop a application. you should download jdk, not jre.
jdk: java develop tookit
jre: java runtime.
linux has an old openjdk, but you can download jdk from oracle website. just download a xx.tar.gz, and untar it into:
/usr/java/jdk1.8xx
and set path:
JAVA_HOME=/usr/java/jdk1.8.0_121
CLASSPATH=.:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar
PATH=$PATH:$JAVA_HOME/bin
export JAVA_HOME PATH CLASSPATH

Oracle java not appearing in SDKMAN?

s#s:~$ sdk ls java
================================================================================
Available Java Versions
================================================================================
13.ea.18-open 10.0.2-zulu
12.0.1-sapmchn 10.0.2-open
12.0.1-zulu 9.0.7-zulu
12.0.1-open 9.0.4-open
12.0.1.j9-adpt 8.0.212-zulu
12.0.1.hs-adpt 8.0.212-amzn
12.0.1-librca > * 8.0.212.j9-adpt
11.0.3-sapmchn 8.0.212.hs-adpt
11.0.3-zulu 8.0.212-librca
11.0.3-amzn 8.0.202-zulufx
11.0.3.j9-adpt 7.0.222-zulu
11.0.3.hs-adpt 6.0.119-zulu
11.0.3-librca 1.0.0-rc-16-grl
11.0.2-open 1.0.0-rc-15-grl
11.0.2-zulufx 1.0.0-rc-14-grl
Why is it missing ORACLE java 8? I need it to test something, and it's available on my other PC, so I'm wondering what the problem could be.
Ubuntu 19.04.
It is no longer supported. This is the github issue for more information.
As the writer said:
The reason that we're moving to OpenJDK is that Oracle doesn't provide
Docker images that are deemed official to Docker, whereas it appears
that OpenJDK ones are as shown there. So if we're going to deploy with
OpenJDK, then we'd like to match our local dev environment as well.

running neo4j in a machine with java 1.6

I am trying to run neo4j for the first time.
In my RHEL 6 machine, I have Java 1.6 installed. I do not want to change that because other programs are using that. When I tried to run neo4j, downloaded from here, I got the error: ERROR! Neo4j cannot be started using java version 1.6.0_24. Please use Oracle(R) Java(TM) 7. Clearly, I need to install JAVA 7. I was wondering if I can just download Java 7 and let neo4j know the path to java executables.
Set the JAVA_HOME and PATH before starting the neo4j server.
set the path on the terminal.
export JAVA_HOME=/home/jdk/jdk1.7.0_45
export PATH=$JAVA_HOME/bin:$PATH
then start the neo4j or you can create a bash script to do this automatically.
The different major versions are normally different packages (e.g., java-1.7.0-openjdk-devel) that go in different directories (usually in /opt), and you can set the JAVA_HOME and/or JDK_HOME environment variables in your startup script. That said, there's rarely any harm in running your programs on the version 7 JVM (just like you can upgrade the kernel without touching your installed programs), and Java 6 is EOL and won't get new security updates.
neo4j 2.0.2 uses java7 it seems and hence requires jdk7.
Go to neo4j website and download 1.8.3 version
http://dist.neo4j.org/neo4j-community-1.8.3-unix.tar.gz
and if you have java 1.6.45 in ubuntu, you are done
untar and copy to /opt and issue the below command from neo4j root directory
sudo ./bin/neo4j start

Multiple Java versions running concurrently under Windows

We have a couple of applications running on Java 5 and would like now to bring in an application based on Java 6. Can both java versions live together under Windows?
Is there any control panel to set the appropriate Java version for different applications, or any other way to set up, what version of Java will be used to run that particular application?
Of course you can use multiple versions of Java under Windows. And different applications can use different Java versions. How is your application started? Usually you will have a batch file where there is something like
java ...
This will search the Java executable using the PATH variable. So if Java 5 is first on the PATH, you will have problems running a Java 6 application. You should then modify the batch file to use a certain Java version e.g. by defining a environment variable JAVA6HOME with the value C:\java\java6 (if Java 6 is installed in this directory) and change the batch file calling
%JAVA6HOME%\bin\java ...
I was appalled at the clumsiness of the CLASSPATH, JAVA_HOME, and PATH ideas, in Windows, to keep track of Java files. I got here, because of multiple JREs, and how to content with it. Without regurgitating information, from a guy much more clever than me, I would rather point to to his article on this issue, which for me, resolves it perfectly.
Article by: Ted Neward: Multiple Java Homes: Giving Java Apps Their Own JRE
With the exponential growth of Java as a server-side development language has come an equivablent
exponential growth in Java development tools, environments, frameworks, and extensions.
Unfortunately, not all of these tools play nicely together under the same Java VM installation. Some
require a Servlet 2.1-compliant environment, some require 2.2. Some only run under JDK 1.2 or above,
some under JDK 1.1 (and no higher). Some require the "com.sun.swing" packages from pre-Swing 1.0
days, others require the "javax.swing" package names.
Worse yet, this problem can be found even within the corporate enterprise, as systems developed using
Java from just six months ago may suddenly "not work" due to the installation of some Java Extension
required by a new (seemingly unrelated) application release. This can complicate deployment of Java
applications across the corporation, and lead customers to wonder precisely why, five years after the
start of the infamous "Installing-this-app-breaks-my-system" woes began with Microsoft's DLL schemes,
we still haven't progressed much beyond that. (In fact, the new .NET initiative actually seeks to solve the
infamous "DLL-Hell" problem just described.)
This paper describes how to configure a Java installation such that a given application receives its own,
private, JRE, allowing multiple Java environments to coexist without driving customers (or system
administrators) insane...
It is absolutely possible to install side-by-side several JRE/JDK versions. Moreover, you don't have to do anything special for that to happen, as Sun is creating a different folder for each (under Program Files).
There is no control panel to check which JRE works for each application. Basically, the JRE that will work would be the first in your PATH environment variable. You can change that, or the JAVA_HOME variable, or create specific cmd/bat files to launch the applications you desire, each with a different JRE in path.
We can install multiple versions of Java Development kits on the same machine using SDKMan.
Some points about SDKMan are as following:
SDKMan is free to use and it is developed by the open source community.
SDKMan is written in bash and it only requires curl and zip/unzip programs to be present on your system.
SDKMan can install around 29 Software Development Kits for the JVM such as Java, Groovy, Scala, Kotlin and Ceylon. Ant, Gradle, Grails, Maven, SBT, Spark, Spring Boot, Vert.x.
We do not need to worry about setting the _HOME and PATH environment variables because SDKMan handles it automatically.
SDKMan can run on any UNIX based platforms such as Mac OSX, Linux, Cygwin, Solaris and FreeBSD and we can install it using following commands:
$ curl -s "https://get.sdkman.io" | bash
$ source "$HOME/.sdkman/bin/sdkman-init.sh"
Because SDKMan is written in bash and only requires curl and zip/unzip to be present on your system. You can install SDKMan on windows as well either by first installing Cygwin or Git Bash for Windows environment and then running above commands.
Command sdk list java will give us a list of java versions which we can install using SDKMan.
Installing Java 8
$ sdk install java 8.0.201-oracle
Installing Java 9
$ sdk install java 9.0.4-open
Installing Java 11
$ sdk install java 11.0.2-open
Uninstalling a Java version
In case you want to uninstall any JDK version e.g., 11.0.2-open you can do that as follows:
$ sdk uninstall java 11.0.2-open
Switching current Java version
If you want to activate one version of JDK for all terminals and applications, you can use the command
sdk default java <your-java_version>
Above commands will also update the PATH and JAVA_HOME variables automatically. You can read more on my article How to Install Multiple Versions of Java on the Same Machine.
It should be possible changing setting the JAVA_HOME environment variable differently for specific applications.
When starting from the command line or from a batch script you can use set JAVA_HOME=C:\...\j2dskXXX to change the JAVA_HOME environment.
It is possible that you also need to change the PATH environment variable to use the correct java binary. To do this you can use set PATH=%JAVA_HOME%\bin;%PATH%.
I use a simple script when starting JMeter with my own java version
setlocal
set JAVA_HOME="c:\java8"
set PATH=%JAVA_HOME%\bin;%PATH%;
java -version
To have a java "portable"
you can use this method here:
https://www.whitebyte.info/programming/java/how-to-install-a-portable-jdk-in-windows-without-admin-rights
Or use links. While it is rather unpleasant to update the PATH in a running environment, it's easy to recreate a link to a new version of JRE/JDK. So:
install different versions of JDK you want to use
create a link to that folder either by junction or by built-in mklink command
set the PATH to the link
If other version of java is to be used, delete the link, create a new one, PATH/JAVA_HOME/hardcoded scripts remain untouched
Invoking Java with "java -version:1.5", etc. should run with the correct version of Java. (Obviously replace 1.5 with the version you want.)
If Java is properly installed on Windows there are paths to the vm for each version stored in the registry which it uses so you don't need to mess about with environment versions on Windows.
If you use Java Web Start (you can start applications from any URL, even the local file system) it will take care of finding the right version for your application.
Using Java Web Start, you can install multiple JRE, then call what you need.
On win, you can make a .bat file:
1- online version:
<your_JRE_version\bin\javaws.exe> -localfile -J-Djnlp.application.href=<the url of .jnlp file.jnlp> -localfile -J "<path_temp_jnlp_file_.jnlp>"
2- launch from cache:
<your_JRE_version\bin\javaws.exe> -localfile -J "<path_of_your_local_jnlp_file.jnlp>"

Categories

Resources